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:
parent
0226405b86
commit
156e20ca73
2 changed files with 17 additions and 6 deletions
11
src/obj.js
11
src/obj.js
|
@ -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;
|
||||
})();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue