Skip to content

Commit

Permalink
Using Adam Klein's suggestion to adopt the same storage strategy on t…
Browse files Browse the repository at this point in the history
…he old/busted HT impl as for new. Faster on Chrome (but we aren't using it there).
  • Loading branch information
slightlyoff committed Apr 30, 2015
1 parent 0610661 commit e0417d6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bin/c.js

Large diffs are not rendered by default.

20 changes: 5 additions & 15 deletions src/HashTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ if (c._functionalMap) {
initialize: function() {
this.size = 0;
this._store = {};
this._keyStrMap = {};
this._deleted = 0;
},

Expand All @@ -155,8 +154,7 @@ if (c._functionalMap) {
// compact or go to a tree.
this.size++;
}
this._store[hash] = value;
this._keyStrMap[hash] = key;
this._store[hash] = [ key, value ];
},

get: function(key) {
Expand All @@ -166,15 +164,14 @@ if (c._functionalMap) {

var v = this._store[key];
if (typeof v != "undefined") {
return this._store[key];
return v[1];
}
return null;
},

clear: function() {
this.size = 0;
this._store = {};
this._keyStrMap = {};
},

_compact: function() {
Expand Down Expand Up @@ -208,9 +205,6 @@ if (c._functionalMap) {
// Sadly, Cassowary is hugely sensitive to iteration order changes, and
// "delete" preserves order when Object.keys() is called later.
delete this._store[key];
// Note: we don't delete from _keyStrMap because we only get the
// Object.keys() from _store, so it's the only one we need to keep up-to-
// date.

if (this.size > 0) {
this.size--;
Expand All @@ -223,10 +217,9 @@ if (c._functionalMap) {
this._perhapsCompact();

var store = this._store;
var keyMap = this._keyStrMap;
for (var x in this._store) {
if (this._store.hasOwnProperty(x)) {
callback.call(scope||null, keyMap[x], store[x]);
callback.call(scope||null, store[x][0], store[x][1]);
}
}
},
Expand All @@ -238,13 +231,12 @@ if (c._functionalMap) {

var that = this;
var store = this._store;
var keyMap = this._keyStrMap;
var context = defaultContext;
var kl = Object.keys(store);
for (var x = 0; x < kl.length; x++) {
(function(v) {
if (that._store.hasOwnProperty(v)) {
context = callback.call(scope||null, keyMap[v], store[v]);
context = callback.call(scope||null, store[v][0], store[v][1]);
}
})(kl[x]);

Expand All @@ -264,7 +256,6 @@ if (c._functionalMap) {
if (this.size) {
n.size = this.size;
copyOwn(this._store, n._store);
copyOwn(this._keyStrMap, n._keyStrMap);
}
return n;
},
Expand All @@ -281,8 +272,7 @@ if (c._functionalMap) {
var codes = Object.keys(this._store);
for (var i = 0; i < codes.length; i++) {
var code = codes[i];
if (this._keyStrMap[code] !== other._keyStrMap[code] ||
this._store[code] !== other._store[code]) {
if (this._store[code][0] !== other._store[code][0]) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tableau.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ c.Tableau = c.inherit({
if (aVar.isExternal) {
// console.log("addRow(): aVar is external:", aVar.name, aVar.hashCode);
this._externalRows.set(aVar, expr);
this._updatedExternals.add(aVar);
// this._updatedExternals.add(aVar);
}
},

Expand Down
2 changes: 1 addition & 1 deletion third_party/benchmarkjs
Submodule benchmarkjs updated 48 files
+2 −3 .gitignore
+7 −0 .npmignore
+25 −29 .travis.yml
+0 −27 CONTRIBUTING.md
+2 −2 LICENSE.txt
+60 −36 README.md
+400 −415 benchmark.js
+2 −12 bower.json
+0 −14 component.json
+208 −216 doc/README.md
+11 −14 doc/parse.php
+2 −2 example/jsperf/index.html
+1 −1 example/jsperf/main.css
+29 −32 example/jsperf/ui.js
+14 −14 package.json
+33 −33 plugin/ui.browserscope.js
+24 −0 test/benchmark.air/.actionScriptProperties
+2 −0 test/benchmark.air/.flexProperties
+24 −0 test/benchmark.air/.project
+6 −0 test/benchmark.air/README.md
+ test/benchmark.air/bin-debug/air.swf
+16 −0 test/benchmark.air/src/air-app.xml
+7 −0 test/benchmark.air/src/air.mxml
+38 −0 test/benchmark.air/src/index.html
+28 −51 test/index.html
+5 −6 test/run-test.sh
+97 −94 test/test.js
+1 −1 vendor/docdown/LICENSE.txt
+35 −0 vendor/docdown/README.md
+1 −1 vendor/docdown/docdown.php
+2 −7 vendor/docdown/src/DocDown/Entry.php
+11 −92 vendor/docdown/src/DocDown/MarkdownGenerator.php
+22 −0 vendor/lodash/LICENSE.txt
+309 −0 vendor/lodash/README.md
+6,726 −0 vendor/lodash/lodash.js
+20 −0 vendor/platform.js/LICENSE.txt
+100 −0 vendor/platform.js/README.md
+1,007 −0 vendor/platform.js/platform.js
+20 −0 vendor/qunit-clib/LICENSE.txt
+60 −0 vendor/qunit-clib/README.md
+343 −0 vendor/qunit-clib/qunit-clib.js
+21 −0 vendor/qunit/MIT-LICENSE.txt
+62 −0 vendor/qunit/README.md
+244 −0 vendor/qunit/qunit/qunit.css
+2,152 −0 vendor/qunit/qunit/qunit.js
+58 −0 vendor/requirejs/LICENSE
+51 −0 vendor/requirejs/README.md
+2,054 −0 vendor/requirejs/require.js

0 comments on commit e0417d6

Please sign in to comment.