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