[Cleanup] Use constant reference and check for empty string properly in dbcore.cpp (#3203)

# Notes
- Passing by constant reference is more performant.
- Checking for empty string with `!= '\0'` is more performant.
- https://pvs-studio.com/en/docs/warnings/v805/
- https://pvs-studio.com/en/docs/warnings/v813/
This commit is contained in:
Alex King
2023-04-05 11:27:50 -04:00
committed by GitHub
parent ff440e16b6
commit 7d03479f41
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -80,7 +80,7 @@ MySQLRequestResult DBcore::QueryDatabase(const std::string& query, bool retryOnF
return r;
}
bool DBcore::DoesTableExist(std::string table_name)
bool DBcore::DoesTableExist(const std::string& table_name)
{
auto results = QueryDatabase(fmt::format("SHOW TABLES LIKE '{}'", table_name));
@@ -136,7 +136,7 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo
/**
* Error logging
*/
if (mysql_errno(mysql) > 0 && strlen(query) > 0) {
if (mysql_errno(mysql) > 0 && query[0] != '\0') {
LogMySQLError("[{}] [{}]\n[{}]", mysql_errno(mysql), mysql_error(mysql), query);
}