[Pkg-javascript-commits] [pdf.js] 26/207: Optimize JPG.js receiveAndExtend for 1 bit case.
David Prévot
taffit at moszumanska.debian.org
Mon Jul 28 15:36:25 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 0a42edf82f1d36a1681e5d770ffd151ee1569958
Author: Fabian Lange <lange.fabian at gmail.com>
Date: Thu Jun 5 12:07:04 2014 +0200
Optimize JPG.js receiveAndExtend for 1 bit case.
Profiling showed that receiveAndExtend is frequently called with the length of
one bit. This happens for example in decodeBaseline.
For a single bit, the loop and shift in receive, as well as the shifts in
receiveAndExtend are overhead.
This shortcut manually calculates the shifts by either returning 1 or -1 from
receiveAndExtend by reading the bit and deciding on the return value.
While it comes with an overhead for each non-one length, the speedup is at about
10% in the hot parse/decode path.
---
src/core/jpg.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/core/jpg.js b/src/core/jpg.js
index 350d695..26de996 100644
--- a/src/core/jpg.js
+++ b/src/core/jpg.js
@@ -159,6 +159,9 @@ var JpegImage = (function jpegImage() {
}
function receiveAndExtend(length) {
+ if (length === 1) {
+ return readBit() === 1 ? 1 : -1;
+ }
var n = receive(length);
if (n >= 1 << (length - 1)) {
return n;
--
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