Skip to content

Instantly share code, notes, and snippets.

@ThisIsMissEm
Created April 13, 2010 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThisIsMissEm/d5965b276cbbec681813 to your computer and use it in GitHub Desktop.
Save ThisIsMissEm/d5965b276cbbec681813 to your computer and use it in GitHub Desktop.
exports.Freelist.prototype.alloc = function(){
var instance;
if(this.list.length){
instance = this.list.shift();
if(instance.hasOwnProperty("onAlloc")){
instance.onAlloc.call(instance);
}
} else {
instance = this.constructor.apply(this, arguments);
}
return instance;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment