Make MapCache, SetCache, and Stack add values left to right.

This commit is contained in:
John-David Dalton
2015-10-06 23:16:56 -07:00
parent 141630f557
commit 1d425b1731

View File

@@ -1773,14 +1773,12 @@
* @param {Array} [values] The values to cache.
*/
function MapCache(values) {
this.__data__ = {
'hash': new Hash,
'map': Map ? new Map : [],
'string': new Hash
};
var length = values ? values.length : 0;
while (length--) {
var entry = values[length];
var index = -1,
length = values ? values.length : 0;
this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash };
while (++index < length) {
var entry = values[index];
this.set(entry[0], entry[1]);
}
}
@@ -1868,10 +1866,12 @@
* @param {Array} [values] The values to cache.
*/
function SetCache(values) {
var index = -1,
length = values ? values.length : 0;
this.__data__ = new MapCache;
var length = values ? values.length : 0;
while (length--) {
this.push(values[length]);
while (++index < length) {
this.push(values[index]);
}
}
@@ -1922,9 +1922,17 @@
* Creates a stack cache object to store key-value pairs.
*
* @private
* @param {Array} [values] The values to cache.
*/
function Stack() {
function Stack(values) {
var index = -1,
length = values ? values.length : 0;
this.__data__ = { 'array': [], 'map': null };
while (++index < length) {
var entry = values[index];
this.set(entry[0], entry[1]);
}
}
/**