1 // This is a free list to avoid creating so many of the same object.
2 exports.FreeList = function(name, max, constructor) {
4 this.constructor = constructor;
10 exports.FreeList.prototype.alloc = function () {
11 //debug("alloc " + this.name + " " + this.list.length);
12 return this.list.length ? this.list.shift()
13 : this.constructor.apply(this, arguments);
17 exports.FreeList.prototype.free = function (obj) {
18 //debug("free " + this.name + " " + this.list.length);
19 if (this.list.length < this.max) {