mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Optimize _.pairs.
Former-commit-id: 1de87609a8635fb8d48bc558fbdabc545da53b4b
This commit is contained in:
@@ -209,7 +209,6 @@ require({
|
||||
* `_.defer`
|
||||
* `_.difference`
|
||||
* `_.each`
|
||||
* `_.escape`
|
||||
* `_.every`, `_.all`
|
||||
* `_.extend`
|
||||
* `_.filter`, `_.select`
|
||||
@@ -220,6 +219,7 @@ require({
|
||||
* `_.groupBy`
|
||||
* `_.indexOf`
|
||||
* `_.intersection`
|
||||
* `_.invert`
|
||||
* `_.invoke`
|
||||
* `_.isArguments`
|
||||
* `_.isDate`
|
||||
@@ -238,6 +238,7 @@ require({
|
||||
* `_.min`
|
||||
* `_.mixin`
|
||||
* `_.omit`
|
||||
* `_.pairs`
|
||||
* `_.pick`
|
||||
* `_.pluck`
|
||||
* `_.reduce`, `_.foldl`, `_.inject`
|
||||
|
||||
2
build.js
2
build.js
@@ -595,7 +595,7 @@
|
||||
.replace(/(?: *\/\/.*\n)*\s*'( *)<% *if *\(isKeysFast[\s\S]+?'\1<% *} *else *\{ *%>.+\n([\s\S]+?) *'\1<% *} *%>.+/, '$2')
|
||||
// remove `isKeysFast` from `beforeLoop.object` of `mapIteratorOptions`
|
||||
.replace(/=\s*'\s*\+\s*\(isKeysFast.+/, "= []'")
|
||||
// remove `isKeysFast` from `inLoop.object` of `mapIteratorOptions`, `invoke`, `pluck`, and `sortBy`
|
||||
// remove `isKeysFast` from `inLoop.object` of `mapIteratorOptions`, `invoke`, `pairs`, `pluck`, and `sortBy`
|
||||
.replace(/'\s*\+\s*\(isKeysFast[^)]+?\)\s*\+\s*'/g, '.push')
|
||||
// remove data object property assignment in `createIterator`
|
||||
.replace(/\s*.+?\.isKeysFast *=.+/, '');
|
||||
|
||||
@@ -1865,7 +1865,7 @@
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Object} object The object to inspect..
|
||||
* @param {Object} object The object to inspect.
|
||||
* @returns {Array} Returns new array of key-value pairs.
|
||||
* @example
|
||||
*
|
||||
@@ -1875,7 +1875,7 @@
|
||||
var pairs = createIterator({
|
||||
'args': 'object',
|
||||
'init':'[]',
|
||||
'inLoop': 'result.push([index, value])'
|
||||
'inLoop': 'result' + (isKeysFast ? '[ownIndex] = ' : '.push') + '([index, value])'
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
24
perf/perf.js
24
perf/perf.js
@@ -864,6 +864,18 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.invert`')
|
||||
.add('Lo-Dash', '\
|
||||
lodash.invert(object)'
|
||||
)
|
||||
.add('Underscore', '\
|
||||
_.invert(object)'
|
||||
)
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.invoke` iterating an array')
|
||||
.add('Lo-Dash', '\
|
||||
@@ -1104,6 +1116,18 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.pairs`')
|
||||
.add('Lo-Dash', '\
|
||||
lodash.pairs(object)'
|
||||
)
|
||||
.add('Underscore', '\
|
||||
_.pairs(object)'
|
||||
)
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.pick`')
|
||||
.add('Lo-Dash', '\
|
||||
|
||||
Reference in New Issue
Block a user