1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Cache Cmd object to reduce number of created objects

This commit is contained in:
Julian Viereck 2011-12-18 20:39:10 +01:00
parent 0226405b86
commit 156e20ca73
2 changed files with 17 additions and 6 deletions

View file

@ -22,6 +22,17 @@ var Cmd = (function CmdClosure() {
Cmd.prototype = {
};
var cmdCache = {};
Cmd.get = function(cmd) {
if (cmdCache[cmd]) {
return cmdCache[cmd];
} else {
return cmdCache[cmd] = new Cmd(cmd);
}
}
return Cmd;
})();