mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
jQuery.ordered_map: remove map attribute
map attribute is redundant and not used. Use `get` method instead. Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
parent
68f04643d6
commit
60997b58b8
@ -30,11 +30,10 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function(map) {
|
||||
*/
|
||||
that.keys = [];
|
||||
that.values = [];
|
||||
that.map = {};
|
||||
that.length = 0;
|
||||
|
||||
that.get = function(key) {
|
||||
return that.map[key];
|
||||
return that.values[that._key_indicies[key]];
|
||||
};
|
||||
|
||||
that.put = function(key, value, position) {
|
||||
@ -60,8 +59,6 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function(map) {
|
||||
}
|
||||
}
|
||||
|
||||
that.map[key] = value;
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
@ -111,11 +108,9 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function(map) {
|
||||
var i = that.get_key_index(key);
|
||||
if (i<0) return null;
|
||||
|
||||
var value = that.values[i];
|
||||
that.keys.splice(i, 1);
|
||||
that.values.splice(i, 1);
|
||||
|
||||
var value = that.map[key];
|
||||
delete that.map[key];
|
||||
delete that._key_indicies[key];
|
||||
that.length = that.keys.length;
|
||||
return value;
|
||||
@ -124,7 +119,6 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function(map) {
|
||||
that.empty = function() {
|
||||
that.keys = [];
|
||||
that.values = [];
|
||||
that.map = {};
|
||||
that._key_indicies = {};
|
||||
that.length = that.keys.length;
|
||||
return that;
|
||||
|
@ -30,7 +30,6 @@ test("Testing $.ordered_map constructor.", function() {
|
||||
strictEqual(test.length, 0, "Checking length.");
|
||||
deepEqual(test.keys, [], "Checking keys.");
|
||||
deepEqual(test.values, [], "Checking values.");
|
||||
deepEqual(test.map, {}, "Checking map.");
|
||||
});
|
||||
|
||||
test("Testing $.ordered_map.put().", function() {
|
||||
@ -84,7 +83,6 @@ test("Testing $.ordered_map.put().", function() {
|
||||
strictEqual(test.length, 8, 'Checking length.');
|
||||
deepEqual(test.keys, [key5, key4, key1, key3, key2, key6, key7, key8], 'Checking keys.');
|
||||
deepEqual(test.values, [value5, value4, value1, value3, value2, value6, value7, value8], 'Checking values.');
|
||||
deepEqual(test.map, map, 'Checking map.');
|
||||
});
|
||||
|
||||
test("Testing $.ordered_map.get().", function() {
|
||||
@ -110,7 +108,6 @@ test("Testing $.ordered_map.get().", function() {
|
||||
strictEqual(test.length, 2, 'Checking length.');
|
||||
deepEqual(test.keys, [key1, key2], 'Checking keys.');
|
||||
deepEqual(test.values, [value1, value2], 'Checking values.');
|
||||
deepEqual(test.map, map, 'Checking map.');
|
||||
strictEqual(result1, value1, 'Checking result 1.');
|
||||
strictEqual(result2, value2, 'Checking result 2.');
|
||||
});
|
||||
@ -136,7 +133,6 @@ test("Testing $.ordered_map.remove().", function() {
|
||||
strictEqual(test.length, 1, 'Checking length.');
|
||||
deepEqual(test.keys, [key2], 'Checking keys.');
|
||||
deepEqual(test.values, [value2], 'Checking values.');
|
||||
deepEqual(test.map, map, 'Checking map.');
|
||||
strictEqual(result1, value1, 'Checking result.');
|
||||
});
|
||||
|
||||
@ -158,7 +154,6 @@ test("Testing $.ordered_map.empty().", function() {
|
||||
strictEqual(test.length, 0, 'Checking length.');
|
||||
deepEqual(test.keys, [], 'Checking keys.');
|
||||
deepEqual(test.values, [], 'Checking values.');
|
||||
deepEqual(test.map, {}, 'Checking map.');
|
||||
});
|
||||
|
||||
};});
|
Loading…
Reference in New Issue
Block a user