| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 55ba1d4 commit 6be4942
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); | |
@@ -389,8 +390,11 @@ EventEmitter.prototype.removeListener = | |||
| 389 | 390 | ||
| 390 | 391 | if (position === 0) | |
| 391 | 392 | list.shift(); | |
| 392 | - else | ||
| 393 | + else { | ||
| 394 | + if (spliceOne === undefined) | ||
| 395 | + spliceOne = require('internal/util').spliceOne; | ||
| 393 | 396 | spliceOne(list, position); | |
| 397 | + } | ||
| 394 | 398 | ||
| 395 | 399 | if (list.length === 1) | |
| 396 | 400 | events[type] = list[0]; | |
@@ -502,13 +506,6 @@ EventEmitter.prototype.eventNames = function eventNames() { | |||
| 502 | 506 | return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; | |
| 503 | 507 | }; | |
| 504 | 508 | ||
| 505 | - // About 1.5x faster than the two-arg version of Array#splice(). | ||
| 506 | - function spliceOne(list, index) { | ||
| 507 | - for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) | ||
| 508 | - list[i] = list[k]; | ||
| 509 | - list.pop(); | ||
| 510 | - } | ||
| 511 | - | ||
| 512 | 509 | function arrayClone(arr, n) { | |
| 513 | 510 | var copy = new Array(n); | |
| 514 | 511 | for (var i = 0; i < n; ++i) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -266,6 +266,13 @@ function join(output, separator) { | |||
| 266 | 266 | return str; | |
| 267 | 267 | } | |
| 268 | 268 | ||
| 269 | + // About 1.5x faster than the two-arg version of Array#splice(). | ||
| 270 | + function spliceOne(list, index) { | ||
| 271 | + for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) | ||
| 272 | + list[i] = list[k]; | ||
| 273 | + list.pop(); | ||
| 274 | + } | ||
| 275 | + | ||
| 269 | 276 | module.exports = { | |
| 270 | 277 | assertCrypto, | |
| 271 | 278 | cachedResult, | |
@@ -276,10 +283,11 @@ module.exports = { | |||
| 276 | 283 | filterDuplicateStrings, | |
| 277 | 284 | getConstructorOf, | |
| 278 | 285 | isError, | |
| 286 | + join, | ||
| 279 | 287 | normalizeEncoding, | |
| 280 | 288 | objectToString, | |
| 281 | 289 | promisify, | |
| 282 | - join, | ||
| 290 | + spliceOne, | ||
| 283 | 291 | ||
| 284 | 292 | // Symbol used to customize promisify conversion | |
| 285 | 293 | customPromisifyArgs: kCustomPromisifyArgsSymbol, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ const { toASCII } = process.binding('config').hasIntl ? | |||
| 25 | 25 | process.binding('icu') : require('punycode'); | |
| 26 | 26 | ||
| 27 | 27 | const { hexTable } = require('internal/querystring'); | |
| 28 | + const { spliceOne } = require('internal/util'); | ||
| 28 | 29 | ||
| 29 | 30 | // WHATWG URL implementation provided by internal/url | |
| 30 | 31 | const { | |
@@ -948,13 +949,6 @@ Url.prototype.parseHost = function parseHost() { | |||
| 948 | 949 | if (host) this.hostname = host; | |
| 949 | 950 | }; | |
| 950 | 951 | ||
| 951 | - // About 1.5x faster than the two-arg version of Array#splice(). | ||
| 952 | - function spliceOne(list, index) { | ||
| 953 | - for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) | ||
| 954 | - list[i] = list[k]; | ||
| 955 | - list.pop(); | ||
| 956 | - } | ||
| 957 | - | ||
| 958 | 952 | // These characters do not need escaping: | |
| 959 | 953 | // ! - . _ ~ | |
| 960 | 954 | // ' ( ) * : | |
| Back | FazBrowse Home | New Git URL |
0 commit comments