Extract completing ODBC connection string into a function

No real changes, this is just a trivial refactoring.
This commit is contained in:
Vadim Zeitlin
2026-01-13 00:04:55 +01:00
parent 4445095407
commit 50da736807

View File

@@ -34,6 +34,19 @@ std::unordered_map<std::string, std::string> completed_connection_strings;
// Mutex protecting the map above from concurrent access.
soci_mutex_t completed_connection_strings_mutex;
// Helper function replacing the given connection string with the previously
// completed version if we have one.
void
complete_connection_string(std::string& connectString)
{
soci_scoped_lock lock(&completed_connection_strings_mutex);
auto const it = completed_connection_strings.find(connectString);
if (it != completed_connection_strings.end())
{
connectString = it->second;
}
}
// Helper function checking if the given option is specified in the connection
// string and returning its value while removing this option (which is supposed
@@ -174,12 +187,7 @@ odbc_session_backend::odbc_session_backend(
// Check if we already have a completed connection string for this
// connection string and use it if we do.
soci_scoped_lock lock(&completed_connection_strings_mutex);
auto const it = completed_connection_strings.find(connectString);
if (it != completed_connection_strings.end())
{
connectString = it->second;
}
complete_connection_string(connectString);
}
}