Skip to content

Commit 29e9f31

Browse files
committed
Use transparent comparator in mColumnNames to avoid creating std::string when comparing
1 parent be5400c commit 29e9f31

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/SQLiteCpp/Statement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ class Statement
703703
bool mbDone{false}; //!< true when the last executeStep() had no more row to fetch
704704

705705
/// Map of columns index by name (mutable so getColumnIndex can be const)
706-
mutable std::map<std::string, int> mColumnNames{};
706+
mutable std::map<std::string, int, std::less<>> mColumnNames{};
707707
};
708708

709709

src/Statement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ int Statement::getColumnIndex(const char* apName) const
275275
for (int i = 0; i < mColumnCount; ++i)
276276
{
277277
const char* pName = sqlite3_column_name(getPreparedStatement(), i);
278-
mColumnNames[pName] = i;
278+
mColumnNames.emplace(pName, i);
279279
}
280280
}
281281

@@ -288,7 +288,7 @@ int Statement::getColumnIndex(const char* apName) const
288288
return iIndex->second;
289289
}
290290

291-
const char * Statement::getColumnDeclaredType(const int aIndex) const
291+
const char* Statement::getColumnDeclaredType(const int aIndex) const
292292
{
293293
checkIndex(aIndex);
294294
const char * result = sqlite3_column_decltype(getPreparedStatement(), aIndex);

0 commit comments

Comments
 (0)