mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Use Array#splice directly.
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
import assocIndexOf from './assocIndexOf.js'
|
import assocIndexOf from './assocIndexOf.js'
|
||||||
|
|
||||||
/** Built-in value references. */
|
|
||||||
const splice = Array.prototype.splice
|
|
||||||
|
|
||||||
class ListCache {
|
class ListCache {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,7 +48,7 @@ class ListCache {
|
|||||||
if (index == lastIndex) {
|
if (index == lastIndex) {
|
||||||
data.pop()
|
data.pop()
|
||||||
} else {
|
} else {
|
||||||
splice.call(data, index, 1)
|
data.splice(index, 1)
|
||||||
}
|
}
|
||||||
--this.size
|
--this.size
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ import baseIndexOf from './baseIndexOf.js'
|
|||||||
import baseIndexOfWith from './baseIndexOfWith.js'
|
import baseIndexOfWith from './baseIndexOfWith.js'
|
||||||
import copyArray from './copyArray.js'
|
import copyArray from './copyArray.js'
|
||||||
|
|
||||||
/** Built-in value references. */
|
|
||||||
const splice = Array.prototype.splice
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `pullAllBy`.
|
* The base implementation of `pullAllBy`.
|
||||||
*
|
*
|
||||||
@@ -36,9 +33,9 @@ function basePullAll(array, values, iteratee, comparator) {
|
|||||||
|
|
||||||
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
|
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
|
||||||
if (seen !== array) {
|
if (seen !== array) {
|
||||||
splice.call(seen, fromIndex, 1)
|
seen.splice(fromIndex, 1)
|
||||||
}
|
}
|
||||||
splice.call(array, fromIndex, 1)
|
array.splice(fromIndex, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array
|
return array
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import baseUnset from './baseUnset.js'
|
import baseUnset from './baseUnset.js'
|
||||||
import isIndex from './isIndex.js'
|
import isIndex from './isIndex.js'
|
||||||
|
|
||||||
/** Built-in value references. */
|
|
||||||
const splice = Array.prototype.splice
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `pullAt` without support for individual
|
* The base implementation of `pullAt` without support for individual
|
||||||
* indexes or capturing the removed elements.
|
* indexes or capturing the removed elements.
|
||||||
@@ -23,7 +20,7 @@ function basePullAt(array, indexes) {
|
|||||||
if (length == lastIndex || index !== previous) {
|
if (length == lastIndex || index !== previous) {
|
||||||
previous = index
|
previous = index
|
||||||
if (isIndex(index)) {
|
if (isIndex(index)) {
|
||||||
splice.call(array, index, 1)
|
array.splice(index, 1)
|
||||||
} else {
|
} else {
|
||||||
baseUnset(array, index)
|
baseUnset(array, index)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user