diff options
author | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2017-06-16 20:14:58 +0300 |
---|---|---|
committer | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2017-06-19 18:07:52 +0300 |
commit | 878990498a246488dfe5393ddc89b2b15f395a4d (patch) | |
tree | 09518527781b28991d44039a40d0a221992b0756 /lib/readline.js | |
parent | b9457717cab131a0f6e58b12f4b65a7aae4ecc30 (diff) | |
download | android-node-v8-878990498a246488dfe5393ddc89b2b15f395a4d.tar.gz android-node-v8-878990498a246488dfe5393ddc89b2b15f395a4d.tar.bz2 android-node-v8-878990498a246488dfe5393ddc89b2b15f395a4d.zip |
readline,repl,url,util: remove needless capturing
Use non-capturing grouping or remove capturing completely when:
* capturing is useless per se, e.g. in test() check;
* captured groups are not used afterwards at all;
* some of the later captured groups are not used afterwards.
PR-URL: https://github.com/nodejs/node/pull/13718
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'lib/readline.js')
-rw-r--r-- | lib/readline.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/readline.js b/lib/readline.js index adf2d5f067..51d1da5770 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -551,7 +551,7 @@ function commonPrefix(strings) { Interface.prototype._wordLeft = function() { if (this.cursor > 0) { var leading = this.line.slice(0, this.cursor); - var match = leading.match(/([^\w\s]+|\w+|)\s*$/); + var match = leading.match(/(?:[^\w\s]+|\w+|)\s*$/); this._moveCursor(-match[0].length); } }; @@ -560,7 +560,7 @@ Interface.prototype._wordLeft = function() { Interface.prototype._wordRight = function() { if (this.cursor < this.line.length) { var trailing = this.line.slice(this.cursor); - var match = trailing.match(/^(\s+|\W+|\w+)\s*/); + var match = trailing.match(/^(?:\s+|\W+|\w+)\s*/); this._moveCursor(match[0].length); } }; @@ -587,7 +587,7 @@ Interface.prototype._deleteRight = function() { Interface.prototype._deleteWordLeft = function() { if (this.cursor > 0) { var leading = this.line.slice(0, this.cursor); - var match = leading.match(/([^\w\s]+|\w+|)\s*$/); + var match = leading.match(/(?:[^\w\s]+|\w+|)\s*$/); leading = leading.slice(0, leading.length - match[0].length); this.line = leading + this.line.slice(this.cursor, this.line.length); this.cursor = leading.length; @@ -599,7 +599,7 @@ Interface.prototype._deleteWordLeft = function() { Interface.prototype._deleteWordRight = function() { if (this.cursor < this.line.length) { var trailing = this.line.slice(this.cursor); - var match = trailing.match(/^(\s+|\W+|\w+)\s*/); + var match = trailing.match(/^(?:\s+|\W+|\w+)\s*/); this.line = this.line.slice(0, this.cursor) + trailing.slice(match[0].length); this._refreshLine(); |