| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 686e092 commit 7a71cd7
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ | |||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | 24 | var domain; | |
| 25 | + var spliceOne; | ||
| 25 | 26 | ||
| 26 | 27 | function EventEmitter() { | |
| 27 | 28 | EventEmitter.init.call(this); | |
@@ -414,8 +415,11 @@ EventEmitter.prototype.removeListener = | |||
| 414 | 415 | ||
| 415 | 416 | if (position === 0) | |
| 416 | 417 | list.shift(); | |
| 417 | - else | ||
| 418 | + else { | ||
| 419 | + if (spliceOne === undefined) | ||
| 420 | + spliceOne = require('internal/util').spliceOne; | ||
| 418 | 421 | spliceOne(list, position); | |
| 422 | + } | ||
| 419 | 423 | ||
| 420 | 424 | if (list.length === 1) | |
| 421 | 425 | events[type] = list[0]; | |
@@ -527,13 +531,6 @@ EventEmitter.prototype.eventNames = function eventNames() { | |||
| 527 | 531 | return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; | |
| 528 | 532 | }; | |
| 529 | 533 | ||
| 530 | - // About 1.5x faster than the two-arg version of Array#splice(). | ||
| 531 | - function spliceOne(list, index) { | ||
| 532 | - for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) | ||
| 533 | - list[i] = list[k]; | ||
| 534 | - list.pop(); | ||
| 535 | - } | ||
| 536 | - | ||
| 537 | 534 | function arrayClone(arr, n) { | |
| 538 | 535 | var copy = new Array(n); | |
| 539 | 536 | for (var i = 0; i < n; ++i) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -271,6 +271,13 @@ function join(output, separator) { | |||
| 271 | 271 | return str; | |
| 272 | 272 | } | |
| 273 | 273 | ||
| 274 | + // About 1.5x faster than the two-arg version of Array#splice(). | ||
| 275 | + function spliceOne(list, index) { | ||
| 276 | + for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) | ||
| 277 | + list[i] = list[k]; | ||
| 278 | + list.pop(); | ||
| 279 | + } | ||
| 280 | + | ||
| 274 | 281 | module.exports = { | |
| 275 | 282 | assertCrypto, | |
| 276 | 283 | cachedResult, | |
@@ -281,10 +288,11 @@ module.exports = { | |||
| 281 | 288 | filterDuplicateStrings, | |
| 282 | 289 | getConstructorOf, | |
| 283 | 290 | isError, | |
| 291 | + join, | ||
| 284 | 292 | normalizeEncoding, | |
| 285 | 293 | objectToString, | |
| 286 | 294 | promisify, | |
| 287 | - join, | ||
| 295 | + spliceOne, | ||
| 288 | 296 | ||
| 289 | 297 | // Symbol used to customize promisify conversion | |
| 290 | 298 | customPromisifyArgs: kCustomPromisifyArgsSymbol, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,6 +28,8 @@ const { hexTable } = require('internal/querystring'); | |||
| 28 | 28 | ||
| 29 | 29 | const errors = require('internal/errors'); | |
| 30 | 30 | ||
| 31 | + const { spliceOne } = require('internal/util'); | ||
| 32 | + | ||
| 31 | 33 | // WHATWG URL implementation provided by internal/url | |
| 32 | 34 | const { | |
| 33 | 35 | URL, | |
@@ -950,13 +952,6 @@ Url.prototype.parseHost = function parseHost() { | |||
| 950 | 952 | if (host) this.hostname = host; | |
| 951 | 953 | }; | |
| 952 | 954 | ||
| 953 | - // About 1.5x faster than the two-arg version of Array#splice(). | ||
| 954 | - function spliceOne(list, index) { | ||
| 955 | - for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) | ||
| 956 | - list[i] = list[k]; | ||
| 957 | - list.pop(); | ||
| 958 | - } | ||
| 959 | - | ||
| 960 | 955 | // These characters do not need escaping: | |
| 961 | 956 | // ! - . _ ~ | |
| 962 | 957 | // ' ( ) * : | |
| Back | FazBrowse Home | New Git URL |
0 commit comments