File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 2222'use strict' ;
2323
2424var domain ;
25+ var spliceOne ;
2526
2627function EventEmitter ( ) {
2728 EventEmitter . init . call ( this ) ;
@@ -416,8 +417,11 @@ EventEmitter.prototype.removeListener =
416417
417418 if ( position === 0 )
418419 list . shift ( ) ;
419- else
420+ else {
421+ if ( spliceOne === undefined )
422+ spliceOne = require ( 'internal/util' ) . spliceOne ;
420423 spliceOne ( list , position ) ;
424+ }
421425
422426 if ( list . length === 1 )
423427 events [ type ] = list [ 0 ] ;
@@ -529,13 +533,6 @@ EventEmitter.prototype.eventNames = function eventNames() {
529533 return this . _eventsCount > 0 ? Reflect . ownKeys ( this . _events ) : [ ] ;
530534} ;
531535
532- // About 1.5x faster than the two-arg version of Array#splice().
533- function spliceOne ( list , index ) {
534- for ( var i = index , k = i + 1 , n = list . length ; k < n ; i += 1 , k += 1 )
535- list [ i ] = list [ k ] ;
536- list . pop ( ) ;
537- }
538-
539536function arrayClone ( arr , n ) {
540537 var copy = new Array ( n ) ;
541538 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) {
271271 return str ;
272272}
273273
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+
274281module . exports = {
275282 assertCrypto,
276283 cachedResult,
@@ -281,10 +288,11 @@ module.exports = {
281288 filterDuplicateStrings,
282289 getConstructorOf,
283290 isError,
291+ join,
284292 normalizeEncoding,
285293 objectToString,
286294 promisify,
287- join ,
295+ spliceOne ,
288296
289297 // Symbol used to customize promisify conversion
290298 customPromisifyArgs : kCustomPromisifyArgsSymbol ,
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ const { hexTable } = require('internal/querystring');
2828
2929const errors = require ( 'internal/errors' ) ;
3030
31+ const { spliceOne } = require ( 'internal/util' ) ;
32+
3133// WHATWG URL implementation provided by internal/url
3234const {
3335 URL ,
@@ -952,13 +954,6 @@ Url.prototype.parseHost = function parseHost() {
952954 if ( host ) this . hostname = host ;
953955} ;
954956
955- // About 1.5x faster than the two-arg version of Array#splice().
956- function spliceOne ( list , index ) {
957- for ( var i = index , k = i + 1 , n = list . length ; k < n ; i += 1 , k += 1 )
958- list [ i ] = list [ k ] ;
959- list . pop ( ) ;
960- }
961-
962957// These characters do not need escaping:
963958// ! - . _ ~
964959// ' ( ) * :
You can’t perform that action at this time.
0 commit comments