[Pkg-javascript-commits] [pdf.js] 131/207: Factor out repeated Ref key string generation code.
David Prévot
taffit at moszumanska.debian.org
Mon Jul 28 15:36:39 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 1ad3ffbc7bf6ad11f6b3e91e2106426a7a2a1c33
Author: Nicholas Nethercote <nnethercote at mozilla.com>
Date: Wed Jun 18 20:41:33 2014 -0700
Factor out repeated Ref key string generation code.
In src/core/obj.js, we convert a Ref to a string to index into a table like
this: 'R1.0'. This conversion is repeated numerous times.
This patch factors out the conversion into a new function.
Ref.prototype.toString().
---
src/core/obj.js | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/core/obj.js b/src/core/obj.js
index af13e5a..73824e4 100644
--- a/src/core/obj.js
+++ b/src/core/obj.js
@@ -218,7 +218,11 @@ var Ref = (function RefClosure() {
this.gen = gen;
}
- Ref.prototype = {};
+ Ref.prototype = {
+ toString: function Ref_toString() {
+ return 'R' + this.num + '.' + this.gen;
+ }
+ };
return Ref;
})();
@@ -232,15 +236,15 @@ var RefSet = (function RefSetClosure() {
RefSet.prototype = {
has: function RefSet_has(ref) {
- return ('R' + ref.num + '.' + ref.gen) in this.dict;
+ return ref.toString() in this.dict;
},
put: function RefSet_put(ref) {
- this.dict['R' + ref.num + '.' + ref.gen] = true;
+ this.dict[ref.toString()] = true;
},
remove: function RefSet_remove(ref) {
- delete this.dict['R' + ref.num + '.' + ref.gen];
+ delete this.dict[ref.toString()];
}
};
@@ -254,19 +258,19 @@ var RefSetCache = (function RefSetCacheClosure() {
RefSetCache.prototype = {
get: function RefSetCache_get(ref) {
- return this.dict['R' + ref.num + '.' + ref.gen];
+ return this.dict[ref.toString()];
},
has: function RefSetCache_has(ref) {
- return ('R' + ref.num + '.' + ref.gen) in this.dict;
+ return ref.toString() in this.dict;
},
put: function RefSetCache_put(ref, obj) {
- this.dict['R' + ref.num + '.' + ref.gen] = obj;
+ this.dict[ref.toString()] = obj;
},
putAlias: function RefSetCache_putAlias(ref, aliasRef) {
- this.dict['R' + ref.num + '.' + ref.gen] = this.get(aliasRef);
+ this.dict[ref.toString()] = this.get(aliasRef);
},
forEach: function RefSetCache_forEach(fn, thisArg) {
@@ -1180,9 +1184,9 @@ var XRef = (function XRefClosure() {
xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
}
if (isDict(xrefEntry)){
- xrefEntry.objId = 'R' + ref.num + '.' + ref.gen;
+ xrefEntry.objId = ref.toString();
} else if (isStream(xrefEntry)) {
- xrefEntry.dict.objId = 'R' + ref.num + '.' + ref.gen;
+ xrefEntry.dict.objId = ref.toString();
}
return xrefEntry;
},
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list