[Pkg-javascript-commits] [pdf.js] 126/157: Optimize text layer: Avoid unneeded .textContent

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 06:46:48 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 47f2c1472303f7f439bc7b56daaf5c8e1066aea8
Author: Rob Wu <rob at robwu.nl>
Date:   Sat Jul 25 10:48:30 2015 +0200

    Optimize text layer: Avoid unneeded .textContent
    
    Built-in DOM properties are slower than plain JS properties.
    A few lines before, textContent is assigned as follows:
      textDiv.textContent = geom.str;
    So replacing textDiv.textContent.length with geom.str.length slightly
    improves performance without side effects.
---
 web/text_layer_builder.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/web/text_layer_builder.js b/web/text_layer_builder.js
index 7483c02..afb8430 100644
--- a/web/text_layer_builder.js
+++ b/web/text_layer_builder.js
@@ -197,7 +197,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
       // We don't bother scaling single-char text divs, because it has very
       // little effect on text highlighting. This makes scrolling on docs with
       // lots of such divs a lot faster.
-      if (textDiv.textContent.length > 1) {
+      if (geom.str.length > 1) {
         if (style.vertical) {
           textDiv.dataset.canvasWidth = geom.height * this.viewport.scale;
         } else {

-- 
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