[gnome-shell] workspace: Use ES6 findIndex() method for getting window index



commit 3730314dd56510a9cff272058b5a18a97cf44b9b
Author: verdre <verdre v0yd nl>
Date:   Mon Nov 19 12:28:29 2018 +0100

    workspace: Use ES6 findIndex() method for getting window index
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/346

 js/ui/workspace.js          | 7 +------
 js/ui/workspaceThumbnail.js | 7 +------
 2 files changed, 2 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 31892e56a..d8410c2e6 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -1206,12 +1206,7 @@ var Workspace = class {
     }
 
     _lookupIndex(metaWindow) {
-        for (let i = 0; i < this._windows.length; i++) {
-            if (this._windows[i].metaWindow == metaWindow) {
-                return i;
-            }
-        }
-        return -1;
+        return this._windows.findIndex(w => w.metaWindow == metaWindow);
     }
 
     containsMetaWindow(metaWindow) {
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index accac398b..e2417010f 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -319,12 +319,7 @@ var WorkspaceThumbnail = class {
     }
 
     _lookupIndex(metaWindow) {
-        for (let i = 0; i < this._windows.length; i++) {
-            if (this._windows[i].metaWindow == metaWindow) {
-                return i;
-            }
-        }
-        return -1;
+        return this._windows.findIndex(w => w.metaWindow == metaWindow);
     }
 
     syncStacking(stackIndices) {


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