[Pkg-javascript-commits] [pdf.js] 43/161: Avoid more allocations in bidi().
David Prévot
taffit at moszumanska.debian.org
Sat Apr 19 14:16:22 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 3759c11f424ed74315ea660b96e861db5fb4350a
Author: Nicholas Nethercote <nnethercote at mozilla.com>
Date: Wed Mar 12 20:17:57 2014 -0700
Avoid more allocations in bidi().
---
src/core/bidi.js | 14 ++++++++------
src/core/evaluator.js | 6 +-----
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/core/bidi.js b/src/core/bidi.js
index 566ed6c..39a15bd 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -140,9 +140,11 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
}
}
- function BidiResult(str, isLTR, vertical) {
- this.str = str;
- this.dir = (vertical ? 'ttb' : (isLTR ? 'ltr' : 'rtl'));
+ function createBidiText(str, isLTR, vertical) {
+ return {
+ str: str,
+ dir: (vertical ? 'ttb' : (isLTR ? 'ltr' : 'rtl'))
+ };
}
// These are used in bidi(), which is called frequently. We re-use them on
@@ -154,7 +156,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
var isLTR = true;
var strLength = str.length;
if (strLength === 0 || vertical) {
- return new BidiResult(str, isLTR, vertical);
+ return createBidiText(str, isLTR, vertical);
}
// Get types and fill arrays
@@ -188,7 +190,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
// - If more than 30% chars are rtl then string is primarily rtl
if (numBidi === 0) {
isLTR = true;
- return new BidiResult(str, isLTR);
+ return createBidiText(str, isLTR);
}
if (startLevel == -1) {
@@ -453,7 +455,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
result += ch;
}
}
- return new BidiResult(result, isLTR);
+ return createBidiText(result, isLTR);
}
return bidi;
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index 2265321..f9d877a 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -812,11 +812,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
if (chunkBuf.length > 0) {
var chunk = chunkBuf.join('');
- var bidiResult = PDFJS.bidi(chunk, -1, font.vertical);
- var bidiText = {
- str: bidiResult.str,
- dir: bidiResult.dir
- };
+ var bidiText = PDFJS.bidi(chunk, -1, font.vertical);
var renderParams = textState.calcRenderParams(preprocessor.ctm);
var fontHeight = textState.fontSize * renderParams.vScale;
var fontAscent = font.ascent ? font.ascent * fontHeight :
--
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