@@ -985,39 +985,38 @@ void Settings::clearDefaultsNoLock()
985
985
}
986
986
987
987
988
- void Settings::registerChangedCallback (std::string name,
989
- setting_changed_callback cbf, void *userdata)
988
+ void Settings::registerChangedCallback (const std::string & name,
989
+ SettingsChangedCallback cbf, void *userdata)
990
990
{
991
- MutexAutoLock lock (m_callbackMutex );
991
+ MutexAutoLock lock (m_callback_mutex );
992
992
m_callbacks[name].push_back (std::make_pair (cbf, userdata));
993
993
}
994
994
995
- void Settings::deregisterChangedCallback (std::string name, setting_changed_callback cbf, void *userdata)
995
+ void Settings::deregisterChangedCallback (const std::string &name,
996
+ SettingsChangedCallback cbf, void *userdata)
996
997
{
997
- MutexAutoLock lock (m_callbackMutex );
998
- std::map<std::string, std::vector<std::pair<setting_changed_callback, void *> > >:: iterator iterToVector = m_callbacks.find (name);
999
- if (iterToVector != m_callbacks. end ())
1000
- {
1001
- std::vector<std::pair<setting_changed_callback, void *> > &vector = iterToVector ->second ;
998
+ MutexAutoLock lock (m_callback_mutex );
999
+ SettingsCallbackMap:: iterator it_cbks = m_callbacks.find (name);
1000
+
1001
+ if (it_cbks != m_callbacks. end ()) {
1002
+ SettingsCallbackList &cbks = it_cbks ->second ;
1002
1003
1003
- std::vector<std::pair<setting_changed_callback, void *> > ::iterator position =
1004
- std::find (vector .begin (), vector .end (), std::make_pair (cbf, userdata));
1004
+ SettingsCallbackList ::iterator position =
1005
+ std::find (cbks .begin (), cbks .end (), std::make_pair (cbf, userdata));
1005
1006
1006
- if (position != vector .end ())
1007
- vector .erase (position);
1007
+ if (position != cbks .end ())
1008
+ cbks .erase (position);
1008
1009
}
1009
1010
}
1010
1011
1011
- void Settings::doCallbacks (const std::string name)
1012
+ void Settings::doCallbacks (const std::string & name) const
1012
1013
{
1013
- MutexAutoLock lock (m_callbackMutex);
1014
- std::map<std::string, std::vector<std::pair<setting_changed_callback, void *> > >::iterator iterToVector = m_callbacks.find (name);
1015
- if (iterToVector != m_callbacks.end ())
1016
- {
1017
- std::vector<std::pair<setting_changed_callback, void *> >::iterator iter;
1018
- for (iter = iterToVector->second .begin (); iter != iterToVector->second .end (); ++iter)
1019
- {
1020
- (iter->first )(name, iter->second );
1021
- }
1014
+ MutexAutoLock lock (m_callback_mutex);
1015
+
1016
+ SettingsCallbackMap::const_iterator it_cbks = m_callbacks.find (name);
1017
+ if (it_cbks != m_callbacks.end ()) {
1018
+ SettingsCallbackList::const_iterator it;
1019
+ for (it = it_cbks->second .begin (); it != it_cbks->second .end (); ++it)
1020
+ (it->first )(name, it->second );
1022
1021
}
1023
1022
}
0 commit comments