[gjs: 1/2] modules/signals: Use array destructuring in _emit
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/2] modules/signals: Use array destructuring in _emit
- Date: Wed, 31 Jul 2019 19:08:09 +0000 (UTC)
commit 721cd913705e581192f4fc9c4f60e582acdb3076
Author: Jonas Dreßler <verdre v0yd nl>
Date: Wed Jul 31 18:26:15 2019 +0200
modules/signals: Use array destructuring in _emit
With ES6, we now have a clean way to do this, let's use it.
modules/signals.js | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
---
diff --git a/modules/signals.js b/modules/signals.js
index 61dbd93c..99181ae0 100644
--- a/modules/signals.js
+++ b/modules/signals.js
@@ -100,7 +100,7 @@ function _disconnectAll() {
}
}
-function _emit(name /* , arg1, arg2 */) {
+function _emit(name, ...args) {
// may not be any signal handlers at all, if not then return
if (!('_signalConnections' in this))
return;
@@ -125,13 +125,7 @@ function _emit(name /* , arg1, arg2 */) {
// which does pass it in. Also if we pass in the emitter here,
// people don't create closures with the emitter in them,
// which would be a cycle.
-
- let arg_array = [ this ];
- // arguments[0] should be signal name so skip it
- length = arguments.length;
- for (i = 1; i < length; ++i) {
- arg_array.push(arguments[i]);
- }
+ let arg_array = [ this, ...args ];
length = handlers.length;
for (i = 0; i < length; ++i) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]