Skip to content

Commit

Permalink
Hashmap limit
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Jun 15, 2013
1 parent 94217b2 commit 053931f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To compile, get the script from http://closure-compiler.googlecode.com/files/compiler-latest.zip
# And put it into ~/.local or change the path below

FILENAME="out.js"
FILENAME="life-compressed.js"

ls -l $FILENAME

Expand Down
11 changes: 9 additions & 2 deletions life.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ function LifeUniverse()
{
/** @const */
var LOAD_FACTOR = .6,
INITIAL_SIZE = 20;
INITIAL_SIZE = 20,
HASHMAP_LIMIT = 24;

var
// last id for nodes
Expand Down Expand Up @@ -684,9 +685,15 @@ function LifeUniverse()
//console.log("collecting garbage ...");
//var t = Date.now();

hashmap_size = hashmap_size << 1 | 1;
if(hashmap_size < (1 << HASHMAP_LIMIT) - 1)
{
hashmap_size = hashmap_size << 1 | 1;
hashmap = [];
}

max_load = hashmap_size * LOAD_FACTOR | 0;


for(var i = 0; i <= hashmap_size; i++)
hashmap[i] = undefined;

Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ var pow2 = (function()
life.set_step(10);
max_fps = 6;

drawer.cell_width = 1 / 128;
drawer.cell_width = 1 / 32;

life.make_center(field, bounds);
life.setup_meta(otca_on, otca_off, field, bounds);
Expand Down

0 comments on commit 053931f

Please sign in to comment.