diff options
author | Weijia Wang <381152119@qq.com> | 2017-10-15 23:59:53 +0800 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2017-10-20 15:51:20 -0400 |
commit | 7a71cd7d0c34b0de4d03cd931710aefdbc95c710 (patch) | |
tree | a927965a6e8fc70d3ba23d7000da6a007b41da85 /lib/url.js | |
parent | 686e092202514dfc3cf93a463e9177a80dd42133 (diff) | |
download | android-node-v8-7a71cd7d0c34b0de4d03cd931710aefdbc95c710.tar.gz android-node-v8-7a71cd7d0c34b0de4d03cd931710aefdbc95c710.tar.bz2 android-node-v8-7a71cd7d0c34b0de4d03cd931710aefdbc95c710.zip |
lib: move duplicate spliceOne into internal/util
lib/url.js and lib/events.js are using the same spliceOne function.
This change is to move it into the internal/util for avoiding duplicate
code.
PR-URL: https://github.com/nodejs/node/pull/16221
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'lib/url.js')
-rw-r--r-- | lib/url.js | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/url.js b/lib/url.js index 72e03e0f9c..3734a0cad6 100644 --- a/lib/url.js +++ b/lib/url.js @@ -28,6 +28,8 @@ const { hexTable } = require('internal/querystring'); const errors = require('internal/errors'); +const { spliceOne } = require('internal/util'); + // WHATWG URL implementation provided by internal/url const { URL, @@ -950,13 +952,6 @@ Url.prototype.parseHost = function parseHost() { if (host) this.hostname = host; }; -// About 1.5x faster than the two-arg version of Array#splice(). -function spliceOne(list, index) { - for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) - list[i] = list[k]; - list.pop(); -} - // These characters do not need escaping: // ! - . _ ~ // ' ( ) * : |