Skip to content

Commit

Permalink
object_pool: Pull available_objs from end of queue #91
Browse files Browse the repository at this point in the history
We don't really care what order we get objects, and this results in developing
nodes an order of magnitude faster.

shift() means the entire array needs to be rebuilt, whereas pop() just means
popping one from the linked list.
  • Loading branch information
lentinj committed Jan 29, 2019
1 parent 9d7329e commit e51b434
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions OZprivate/rawJS/OZTreeModule/src/util/object_pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class ObjectPool {
this.create_new_obj(i, i-prev_size);
}
}
let first_available = this.available_obj.shift();
return this.arr[first_available];
return this.arr[this.available_obj.pop()];
}
create_new_obj(index_in_arr, available_index) {
this.arr[index_in_arr] = new this.ClassType();
Expand Down

0 comments on commit e51b434

Please sign in to comment.