From 04a4c2e8ef8b487ba474550a00153b01078a6a4c Mon Sep 17 00:00:00 2001 From: Kacperos155 Date: Sat, 23 Jul 2022 16:12:44 +0200 Subject: [PATCH] Use transparent comparator in mColumnNames to avoid creating std::string when comparing --- include/SQLiteCpp/Statement.h | 2 +- src/Statement.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/SQLiteCpp/Statement.h b/include/SQLiteCpp/Statement.h index 75ba757..4982352 100644 --- a/include/SQLiteCpp/Statement.h +++ b/include/SQLiteCpp/Statement.h @@ -703,7 +703,7 @@ private: bool mbDone{false}; //!< true when the last executeStep() had no more row to fetch /// Map of columns index by name (mutable so getColumnIndex can be const) - mutable std::map mColumnNames; + mutable std::map> mColumnNames{}; }; diff --git a/src/Statement.cpp b/src/Statement.cpp index 64e16d2..bef22b0 100644 --- a/src/Statement.cpp +++ b/src/Statement.cpp @@ -275,7 +275,7 @@ int Statement::getColumnIndex(const char* apName) const for (int i = 0; i < mColumnCount; ++i) { const char* pName = sqlite3_column_name(getPreparedStatement(), i); - mColumnNames[pName] = i; + mColumnNames.emplace(pName, i); } } @@ -288,7 +288,7 @@ int Statement::getColumnIndex(const char* apName) const return iIndex->second; } -const char * Statement::getColumnDeclaredType(const int aIndex) const +const char* Statement::getColumnDeclaredType(const int aIndex) const { checkIndex(aIndex); const char * result = sqlite3_column_decltype(getPreparedStatement(), aIndex);