[polari] cleanup: Avoid apply() where possible



commit ad159cc666da84ae5313bcc5c190f0365465ff23
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Aug 6 17:43:16 2019 +0200

    cleanup: Avoid apply() where possible
    
    Invoking functions via Function.prototype.apply() and .call() is
    less performant than a regular function call, and makes code harder
    to read.
    
    Since ES6 added the spread operator, we have a better alternative
    available, so use that.
    
    https://gitlab.gnome.org/GNOME/polari/merge_requests/133

 src/chatView.js   | 2 +-
 src/mainWindow.js | 2 +-
 src/utils.js      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 31e5ed2..64a8106 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -613,7 +613,7 @@ var ChatView = GObject.registerClass({
         }
         // Remove entries that are also in pending (if any), then
         // add the entries from pending
-        logs.splice.apply(logs, [pos, numLogs, ...pending]);
+        logs.splice(pos, numLogs, ...pending);
     }
 
     _insertPendingLogs() {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 179bf9a..4e1708d 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -204,7 +204,7 @@ var MainWindow = GObject.registerClass({
 
         let size = this._settings.get_value('window-size').deep_unpack();
         if (size.length == 2)
-            this.set_default_size.apply(this, size);
+            this.set_default_size(...size);
 
         if (this._settings.get_boolean('window-maximized'))
             this.maximize();
diff --git a/src/utils.js b/src/utils.js
index 346101d..80d6854 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -197,7 +197,7 @@ function updateTerms(terms, str) {
         changed = terms[i] != newTerms[i];
 
     if (changed)
-        terms.splice.apply(terms, [0, terms.length, ...newTerms]);
+        terms.splice(0, terms.length, ...newTerms);
 
     return changed;
 }


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