mirror of
https://github.com/allankoechke/soci.git
synced 2026-11-30 10:58:24 +00:00
Extract completing ODBC connection string into a function
No real changes, this is just a trivial refactoring.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user