[gnome-shell] Remove our custom hashmap implementation



commit bfb0235fc6cc1b121edbae3e6b243b5c01fa05c7
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Jan 14 23:49:47 2014 +0100

    Remove our custom hashmap implementation
    
    gjs uses Spidermonkey 24, which implements Map from the ES6
    specification, so we can use that instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722210

 js/js-resources.gresource.xml |    1 -
 js/misc/hash.js               |  144 -----------------------------------------
 js/ui/messageTray.js          |   10 ++--
 js/ui/screenShield.js         |    8 +--
 js/ui/screencast.js           |    8 +--
 js/ui/shellDBus.js            |   10 +--
 js/ui/status/network.js       |   20 +++---
 7 files changed, 24 insertions(+), 177 deletions(-)
---
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index 339fc0a..0369708 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -15,7 +15,6 @@
     <file>misc/extensionUtils.js</file>
     <file>misc/fileUtils.js</file>
     <file>misc/gnomeSession.js</file>
-    <file>misc/hash.js</file>
     <file>misc/history.js</file>
     <file>misc/jsParse.js</file>
     <file>misc/loginManager.js</file>
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 06609c5..6503611 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -19,7 +19,6 @@ const BoxPointer = imports.ui.boxpointer;
 const CtrlAltTab = imports.ui.ctrlAltTab;
 const GnomeSession = imports.misc.gnomeSession;
 const GrabHelper = imports.ui.grabHelper;
-const Hash = imports.misc.hash;
 const Lightbox = imports.ui.lightbox;
 const Main = imports.ui.main;
 const PointerWatcher = imports.ui.pointerWatcher;
@@ -1899,7 +1898,7 @@ const MessageTray = new Lang.Class({
                               Shell.KeyBindingMode.OVERVIEW,
                               Lang.bind(this, this._expandActiveNotification));
 
-        this._sources = new Hash.Map();
+        this._sources = new Map();
         this._chatSummaryItemsCount = 0;
 
         this._trayDwellTimeoutId = 0;
@@ -1936,7 +1935,7 @@ const MessageTray = new Lang.Class({
     },
 
     _updateNoMessagesLabel: function() {
-        this._noMessages.visible = this._sources.size() == 0;
+        this._noMessages.visible = this._sources.size == 0;
     },
 
     _sessionUpdated: function() {
@@ -2099,7 +2098,8 @@ const MessageTray = new Lang.Class({
     },
 
     _removeSource: function(source) {
-        let [, obj] = this._sources.delete(source);
+        let obj = this._sources.get(source);
+        this._sources.delete(source);
         let summaryItem = obj.summaryItem;
 
         if (source.isChat)
@@ -2120,7 +2120,7 @@ const MessageTray = new Lang.Class({
     },
 
     getSources: function() {
-        return this._sources.keys();
+        return [k for (k of this._sources.keys())];
     },
 
     _onSourceEnableChanged: function(policy, source) {
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index 0ce1528..93dc812 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -17,7 +17,6 @@ const TweenerEquations = imports.tweener.equations;
 
 const Background = imports.ui.background;
 const GnomeSession = imports.misc.gnomeSession;
-const Hash = imports.misc.hash;
 const Layout = imports.ui.layout;
 const OVirt = imports.gdm.oVirt;
 const LoginManager = imports.misc.loginManager;
@@ -115,7 +114,7 @@ const NotificationsBox = new Lang.Class({
         this.actor.add(this._musicBin);
         this.actor.add(this._scrollView, { x_fill: true, x_align: St.Align.START });
 
-        this._sources = new Hash.Map();
+        this._sources = new Map();
         Main.messageTray.getSources().forEach(Lang.bind(this, function(source) {
             this._sourceAdded(Main.messageTray, source, true);
         }));
@@ -130,9 +129,8 @@ const NotificationsBox = new Lang.Class({
             this._sourceAddedId = 0;
         }
 
-        let items = this._sources.items();
-        for (let i = 0; i < items.length; i++) {
-            let [source, obj] = items[i];
+        let items = this._sources.entries();
+        for (let [source, obj] of items) {
             this._removeSource(source, obj);
         }
 
diff --git a/js/ui/screencast.js b/js/ui/screencast.js
index 7908ff1..e2fb8c8 100644
--- a/js/ui/screencast.js
+++ b/js/ui/screencast.js
@@ -6,7 +6,6 @@ const Lang = imports.lang;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 
-const Hash = imports.misc.hash;
 const Main = imports.ui.main;
 
 const ScreencastIface = '<node> \
@@ -42,13 +41,13 @@ const ScreencastService = new Lang.Class({
 
         Gio.DBus.session.own_name('org.gnome.Shell.Screencast', Gio.BusNameOwnerFlags.REPLACE, null, null);
 
-        this._recorders = new Hash.Map();
+        this._recorders = new Map();
 
         Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
     },
 
     get isRecording() {
-        return this._recorders.size() > 0;
+        return this._recorders.size > 0;
     },
 
     _ensureRecorderForSender: function(sender) {
@@ -69,8 +68,7 @@ const ScreencastService = new Lang.Class({
         if (Main.sessionMode.allowScreencast)
             return;
 
-        for (let sender in this._recorders.keys())
-            this._recorders.delete(sender);
+        this._recorders.clear();
         this.emit('updated');
     },
 
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index 4049095..2bc149c 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -10,7 +10,6 @@ const Config = imports.misc.config;
 const ExtensionSystem = imports.ui.extensionSystem;
 const ExtensionDownloader = imports.ui.extensionDownloader;
 const ExtensionUtils = imports.misc.extensionUtils;
-const Hash = imports.misc.hash;
 const Main = imports.ui.main;
 const Screenshot = imports.ui.screenshot;
 const ViewSelector = imports.ui.viewSelector;
@@ -83,8 +82,8 @@ const GnomeShell = new Lang.Class({
         this._extensionsService = new GnomeShellExtensions();
         this._screenshotService = new Screenshot.ScreenshotService();
 
-        this._grabbedAccelerators = new Hash.Map();
-        this._grabbers = new Hash.Map();
+        this._grabbedAccelerators = new Map();
+        this._grabbers = new Map();
 
         global.display.connect('accelerator-activated', Lang.bind(this,
             function(display, action, deviceid, timestamp) {
@@ -228,9 +227,8 @@ const GnomeShell = new Lang.Class({
     },
 
     _onGrabberBusNameVanished: function(connection, name) {
-        let grabs = this._grabbedAccelerators.items();
-        for (let i = 0; i < grabs.length; i++) {
-            let [action, sender] = grabs[i];
+        let grabs = this._grabbedAccelerators.entries();
+        for (let [action, sender] of grabs) {
             if (sender == name)
                 this._ungrabAccelerator(action);
         }
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 1df01b6..c3212cc 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -11,7 +11,6 @@ const NMGtk = imports.gi.NMGtk;
 const Signals = imports.signals;
 const St = imports.gi.St;
 
-const Hash = imports.misc.hash;
 const Main = imports.ui.main;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
@@ -176,7 +175,7 @@ const NMConnectionSection = new Lang.Class({
     _init: function(client) {
         this._client = client;
 
-        this._connectionItems = new Hash.Map();
+        this._connectionItems = new Map();
         this._connections = [];
 
         this._labelSection = new PopupMenu.PopupMenuSection();
@@ -194,7 +193,7 @@ const NMConnectionSection = new Lang.Class({
     },
 
     _sync: function() {
-        let nItems = this._connectionItems.size();
+        let nItems = this._connectionItems.size;
 
         this._switchSection.actor.visible = (nItems > 1);
         this._labelSection.actor.visible = (nItems == 1);
@@ -213,8 +212,7 @@ const NMConnectionSection = new Lang.Class({
 
     _getStatus: function() {
         let values = this._connectionItems.values();
-        for (let i = 0; i < values.length; i++) {
-            let item = values[i];
+        for (let item of values) {
             if (item.isActive())
                 return item.getName();
         }
@@ -365,7 +363,7 @@ const NMConnectionDevice = new Lang.Class({
     },
 
     _sync: function() {
-        let nItems = this._connectionItems.size();
+        let nItems = this._connectionItems.size;
         this._autoConnectItem.actor.visible = (nItems == 0);
         this.parent();
     },
@@ -1217,7 +1215,7 @@ const NMVPNSection = new Lang.Class({
     },
 
     _sync: function() {
-        let nItems = this._connectionItems.size();
+        let nItems = this._connectionItems.size;
         this.item.actor.visible = (nItems > 0);
         this.parent();
     },
@@ -1239,9 +1237,10 @@ const NMVPNSection = new Lang.Class({
     },
 
     setActiveConnections: function(vpnConnections) {
-        this._connectionItems.values().forEach(function(item) {
+        let connections = this._connectionItems.values();
+        for (let item of connections) {
             item.setActiveConnection(null);
-        });
+        }
         vpnConnections.forEach(Lang.bind(this, function(a) {
             let item = this._connectionItems.get(a._connection.get_uuid());
             item.setActiveConnection(a);
@@ -1254,8 +1253,7 @@ const NMVPNSection = new Lang.Class({
 
     getIndicatorIcon: function() {
         let items = this._connectionItems.values();
-        for (let i = 0; i < items.length; i++) {
-            let item = items[i];
+        for (let item of items) {
             let icon = item.getIndicatorIcon();
             if (icon)
                 return icon;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]