diff options
| -rw-r--r-- | UnityCore/DBusIndicators.cpp | 10 | ||||
| -rw-r--r-- | UnityCore/GLibDBusServer.cpp | 5 | ||||
| -rw-r--r-- | UnityCore/GLibSource.h | 4 | ||||
| -rw-r--r-- | UnityCore/pch/unitycore_pch.hh | 1 | ||||
| -rw-r--r-- | dash/DashView.h | 2 | ||||
| -rw-r--r-- | dash/ScopeView.h | 3 | ||||
| -rw-r--r-- | decorations/DecorationsPriv.h | 2 | ||||
| -rw-r--r-- | launcher/LauncherEntryRemoteModel.h | 4 | ||||
| -rw-r--r-- | panel/PanelIndicatorsView.h | 2 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 2 | ||||
| -rw-r--r-- | shortcuts/ShortcutModel.h | 6 | ||||
| -rw-r--r-- | tests/mock-application.h | 4 | ||||
| -rw-r--r-- | unity-shared/IconLoader.cpp | 4 | ||||
| -rw-r--r-- | unity-shared/NuxObjectPtrHash.h | 36 | ||||
| -rw-r--r-- | unity-shared/PluginAdapter.h | 2 | ||||
| -rw-r--r-- | unity-shared/PreviewStyle.cpp | 2 | ||||
| -rw-r--r-- | unity-shared/UBusWrapper.cpp | 9 | ||||
| -rw-r--r-- | unity-shared/UBusWrapper.h | 4 |
18 files changed, 70 insertions, 32 deletions
diff --git a/UnityCore/DBusIndicators.cpp b/UnityCore/DBusIndicators.cpp index a696789b6..1745707be 100644 --- a/UnityCore/DBusIndicators.cpp +++ b/UnityCore/DBusIndicators.cpp @@ -75,7 +75,7 @@ struct DBusIndicators::Impl glib::Source::UniquePtr show_entry_idle_; glib::Source::UniquePtr show_appmenu_idle_; std::vector<std::string> icon_paths_; - std::map<std::string, EntryLocationMap> cached_locations_; + std::unordered_map<std::string, EntryLocationMap> cached_locations_; }; @@ -335,7 +335,7 @@ void DBusIndicators::Impl::Sync(GVariant* args, glib::Error const& error) gboolean image_visible = false; gint32 priority = -1; - std::map<Indicator::Ptr, Indicator::Entries> indicators; + std::unordered_map<Indicator::Ptr, Indicator::Entries> indicators; g_variant_get(args, "(" ENTRY_ARRAY_SIGNATURE ")", &iter); while (g_variant_iter_loop(iter, ENTRY_SIGNATURE, @@ -393,10 +393,8 @@ void DBusIndicators::Impl::Sync(GVariant* args, glib::Error const& error) } g_variant_iter_free(iter); - for (auto i = indicators.begin(), end = indicators.end(); i != end; ++i) - { - i->first->Sync(indicators[i->first]); - } + for (auto const& i : indicators) + i.first->Sync(i.second); } void DBusIndicators::Impl::SyncGeometries(std::string const& name, diff --git a/UnityCore/GLibDBusServer.cpp b/UnityCore/GLibDBusServer.cpp index 0cd3137c4..6d01f5994 100644 --- a/UnityCore/GLibDBusServer.cpp +++ b/UnityCore/GLibDBusServer.cpp @@ -17,6 +17,7 @@ * Authored by: Marco Trevisan (TreviƱo) <marco.trevisan@canonical.com> */ +#include <unordered_map> #include <NuxCore/Logger.h> #include "GLibDBusServer.h" @@ -406,8 +407,8 @@ struct DBusObject::Impl GDBusInterfaceVTable interface_vtable_; std::shared_ptr<GDBusInterfaceInfo> interface_info_; - std::map<guint, std::string> registrations_; - std::map<std::string, glib::Object<GDBusConnection>> connection_by_path_; + std::unordered_map<guint, std::string> registrations_; + std::unordered_map<std::string, glib::Object<GDBusConnection>> connection_by_path_; }; DBusObject::DBusObject(std::string const& introspection_xml, std::string const& interface_name) diff --git a/UnityCore/GLibSource.h b/UnityCore/GLibSource.h index 373b9ad04..061fa2b69 100644 --- a/UnityCore/GLibSource.h +++ b/UnityCore/GLibSource.h @@ -24,7 +24,7 @@ #include <sigc++/sigc++.h> #include <glib.h> #include <memory> -#include <map> +#include <unordered_map> namespace unity { @@ -223,7 +223,7 @@ public: Source::Ptr GetSource(unsigned int id) const; protected: // For testing purposes - typedef std::map<std::string, Source::Ptr> SourcesMap; + typedef std::unordered_map<std::string, Source::Ptr> SourcesMap; SourcesMap sources_; private: diff --git a/UnityCore/pch/unitycore_pch.hh b/UnityCore/pch/unitycore_pch.hh index 6fdf1d30e..d0b76b782 100644 --- a/UnityCore/pch/unitycore_pch.hh +++ b/UnityCore/pch/unitycore_pch.hh @@ -29,6 +29,7 @@ #include <map> #include <memory> #include <unordered_map> +#include <functional> #include <boost/utility.hpp> #include <dee.h> diff --git a/dash/DashView.h b/dash/DashView.h index 54e7df603..b69f2b17d 100644 --- a/dash/DashView.h +++ b/dash/DashView.h @@ -56,7 +56,7 @@ class DashLayout; class DashView : public nux::View, public unity::debug::Introspectable { NUX_DECLARE_OBJECT_TYPE(DashView, nux::View); - typedef std::map<std::string, nux::ObjectPtr<ScopeView>> ScopeViews; + typedef std::unordered_map<std::string, nux::ObjectPtr<ScopeView>> ScopeViews; public: DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter); diff --git a/dash/ScopeView.h b/dash/ScopeView.h index b229a072e..66da53130 100644 --- a/dash/ScopeView.h +++ b/dash/ScopeView.h @@ -35,6 +35,7 @@ #include "unity-shared/Introspectable.h" #include "PlacesGroup.h" #include "ResultViewGrid.h" +#include "unity-shared/NuxObjectPtrHash.h" #include "unity-shared/UBusWrapper.h" namespace unity @@ -48,7 +49,7 @@ class ScopeView : public nux::View, public unity::debug::Introspectable { NUX_DECLARE_OBJECT_TYPE(ScopeView, nux::View); typedef std::vector<PlacesGroup::Ptr> CategoryGroups; - typedef std::map<PlacesGroup::Ptr, unsigned int> ResultCounts; + typedef std::unordered_map<PlacesGroup::Ptr, unsigned int> ResultCounts; public: ScopeView(Scope::Ptr const& scope, nux::Area* show_filters); diff --git a/decorations/DecorationsPriv.h b/decorations/DecorationsPriv.h index 5b1fee373..4c3886b16 100644 --- a/decorations/DecorationsPriv.h +++ b/decorations/DecorationsPriv.h @@ -196,7 +196,7 @@ private: uweak_ptr<decoration::Window> active_deco_win_; uweak_ptr<InputMixer> last_mouse_owner_; - std::map<CompWindow*, decoration::Window::Ptr> windows_; + std::unordered_map<CompWindow*, decoration::Window::Ptr> windows_; std::unordered_map<::Window, std::weak_ptr<decoration::Window>> framed_windows_; menu::Manager::Ptr menu_manager_; diff --git a/launcher/LauncherEntryRemoteModel.h b/launcher/LauncherEntryRemoteModel.h index cf3c0b416..3877e2551 100644 --- a/launcher/LauncherEntryRemoteModel.h +++ b/launcher/LauncherEntryRemoteModel.h @@ -22,7 +22,7 @@ #include <gio/gio.h> #include <sigc++/sigc++.h> -#include <map> +#include <unordered_map> #include "LauncherEntryRemote.h" @@ -68,7 +68,7 @@ private: glib::Object<GDBusConnection> _conn; unsigned int _launcher_entry_dbus_signal_id; unsigned int _dbus_name_owner_changed_signal_id; - std::map<std::string, LauncherEntryRemote::Ptr> _entries_by_uri; + std::unordered_map<std::string, LauncherEntryRemote::Ptr> _entries_by_uri; }; } // namespace diff --git a/panel/PanelIndicatorsView.h b/panel/PanelIndicatorsView.h index 8b3956b4c..bb11df48b 100644 --- a/panel/PanelIndicatorsView.h +++ b/panel/PanelIndicatorsView.h @@ -97,7 +97,7 @@ protected: void RemoveEntryView(PanelIndicatorEntryView* view); nux::HLayout* layout_; - std::map<indicator::Entry::Ptr, PanelIndicatorEntryView*> entries_; + std::unordered_map<indicator::Entry::Ptr, PanelIndicatorEntryView*> entries_; int monitor_; bool overlay_showing_; diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 934399a72..f8dd53309 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -369,7 +369,7 @@ private: typedef std::vector<CompActionPtr> ShortcutActions; ShortcutActions _shortcut_actions; std::map<CancelActionTarget, CompActionPtr> _escape_actions; - std::map<int, unsigned int> windows_for_monitor_; + std::unordered_map<int, unsigned int> windows_for_monitor_; /* keyboard-nav mode */ CompWindow* newFocusedWindow; diff --git a/shortcuts/ShortcutModel.h b/shortcuts/ShortcutModel.h index ed656b251..3dd0024cf 100644 --- a/shortcuts/ShortcutModel.h +++ b/shortcuts/ShortcutModel.h @@ -21,7 +21,7 @@ #define UNITYSHELL_SHORTCUS_MODEL_H #include <boost/noncopyable.hpp> -#include <map> +#include <unordered_map> #include <memory> #include <list> #include <string> @@ -43,7 +43,7 @@ public: nux::Property<int> categories_per_column; std::vector<std::string> const& categories() const { return categories_; } - std::map<std::string, std::list<AbstractHint::Ptr>> const& hints() const { return hints_; } + std::unordered_map<std::string, std::list<AbstractHint::Ptr>> const& hints() const { return hints_; } void Fill(); @@ -51,7 +51,7 @@ private: void AddHint(AbstractHint::Ptr const& hint); std::vector<std::string> categories_; - std::map<std::string, std::list<AbstractHint::Ptr>> hints_; + std::unordered_map<std::string, std::list<AbstractHint::Ptr>> hints_; }; } diff --git a/tests/mock-application.h b/tests/mock-application.h index 4e4c0ad26..1819509f2 100644 --- a/tests/mock-application.h +++ b/tests/mock-application.h @@ -20,7 +20,7 @@ #ifndef TESTS_MOCK_APPLICATION_H #define TESTS_MOCK_APPLICATION_H -#include <map> +#include <unordered_map> #include <gmock/gmock.h> #include <gio/gdesktopappinfo.h> #include <UnityCore/GLibWrapper.h> @@ -360,7 +360,7 @@ struct MockApplicationManager : public unity::ApplicationManager } private: - typedef std::map<std::string, unity::ApplicationPtr> AppMap; + typedef std::unordered_map<std::string, unity::ApplicationPtr> AppMap; AppMap app_map_; }; diff --git a/unity-shared/IconLoader.cpp b/unity-shared/IconLoader.cpp index 021eb6dcf..67686f4e9 100644 --- a/unity-shared/IconLoader.cpp +++ b/unity-shared/IconLoader.cpp @@ -799,7 +799,7 @@ private: bool CoalesceTasksCb(); private: - std::map<std::string, glib::Object<GdkPixbuf>> cache_; + std::unordered_map<std::string, glib::Object<GdkPixbuf>> cache_; /* FIXME: the reference counting of IconLoaderTasks with shared pointers * is currently somewhat broken, and the queued_tasks_ member is what keeps * it from crashing randomly. @@ -807,7 +807,7 @@ private: * tasks, but when they are being completed in a worker thread, the thread * should own them as well (yet it doesn't), this could cause trouble * in the future... You've been warned! */ - std::map<std::string, IconLoaderTask::Ptr> queued_tasks_; + std::unordered_map<std::string, IconLoaderTask::Ptr> queued_tasks_; std::queue<IconLoaderTask::Ptr> tasks_; std::unordered_map<Handle, IconLoaderTask::Ptr> task_map_; std::vector<IconLoaderTask*> finished_tasks_; diff --git a/unity-shared/NuxObjectPtrHash.h b/unity-shared/NuxObjectPtrHash.h new file mode 100644 index 000000000..141957c35 --- /dev/null +++ b/unity-shared/NuxObjectPtrHash.h @@ -0,0 +1,36 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2015 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> + */ + +#ifndef NUX_OBJECT_PTR_HASH +#define NUX_OBJECT_PTR_HASH + +#include <functional> +namespace std +{ +// Template specialization, needed for unordered_{map,set} +template<typename T> struct hash<nux::ObjectPtr<T>> +{ + std::size_t operator()(nux::ObjectPtr<T> const& o) const + { + return std::hash<T*>()(o.GetPointer()); + } +}; +} + +#endif // NUX_OBJECT_PTR_HASH diff --git a/unity-shared/PluginAdapter.h b/unity-shared/PluginAdapter.h index d0a2ec7d7..1c6b4a18b 100644 --- a/unity-shared/PluginAdapter.h +++ b/unity-shared/PluginAdapter.h @@ -50,7 +50,7 @@ private: CompAction* GetAction(std::string const& name) const; CompAction* primary_action_; - std::map<std::string, CompAction*> actions_; + std::unordered_map<std::string, CompAction*> actions_; }; diff --git a/unity-shared/PreviewStyle.cpp b/unity-shared/PreviewStyle.cpp index f9f99e738..c165bca12 100644 --- a/unity-shared/PreviewStyle.cpp +++ b/unity-shared/PreviewStyle.cpp @@ -83,7 +83,7 @@ private: } private: std::string filename_; - std::map<int, BaseTexturePtr> textures_; + std::unordered_map<int, BaseTexturePtr> textures_; }; } // namespace diff --git a/unity-shared/UBusWrapper.cpp b/unity-shared/UBusWrapper.cpp index ecdd39d68..3f1699923 100644 --- a/unity-shared/UBusWrapper.cpp +++ b/unity-shared/UBusWrapper.cpp @@ -32,11 +32,12 @@ UBusManager::UBusManager() UBusManager::~UBusManager() { - // we don't want to modify a container while iterating it - std::set<unsigned> ids_copy(connection_ids_); - for (auto it = ids_copy.begin(); it != ids_copy.end(); ++it) + for (auto it = connection_ids_.begin(); it != connection_ids_.end();) { - UnregisterInterest(*it); + auto tmp_it = it; + ++it; + server->UnregisterInterest(*tmp_it); + connection_ids_.erase(tmp_it); } } diff --git a/unity-shared/UBusWrapper.h b/unity-shared/UBusWrapper.h index 764efea1c..56a111a5b 100644 --- a/unity-shared/UBusWrapper.h +++ b/unity-shared/UBusWrapper.h @@ -22,7 +22,7 @@ #include <memory> #include <string> -#include <set> +#include <unordered_set> #include <UnityCore/Variant.h> #include <UnityCore/GLibSource.h> @@ -47,7 +47,7 @@ public: private: static std::unique_ptr<UBusServer> server; - std::set<unsigned> connection_ids_; + std::unordered_set<unsigned> connection_ids_; }; } |
