[Pkg-javascript-commits] [pdf.js] 142/246: Avoid repeated creation of a simple RegExp object.

David Prévot taffit at moszumanska.debian.org
Sun Sep 7 15:36:34 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 be29fc44e0bbd18563775bf75182a740f2b8332c
Author: Nicholas Nethercote <nnethercote at mozilla.com>
Date:   Thu Aug 7 22:06:12 2014 -0700

    Avoid repeated creation of a simple RegExp object.
---
 web/text_layer_builder.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/web/text_layer_builder.js b/web/text_layer_builder.js
index 19b54cc..03fbcf7 100644
--- a/web/text_layer_builder.js
+++ b/web/text_layer_builder.js
@@ -22,6 +22,12 @@ var FIND_SCROLL_OFFSET_LEFT = -400;
 var MAX_TEXT_DIVS_TO_RENDER = 100000;
 var RENDER_DELAY = 200; // ms
 
+var NonWhitespaceRegexp = /\S/;
+
+function isAllWhitespace(str) {
+  return !NonWhitespaceRegexp.test(str);
+}
+
 /**
  * TextLayerBuilder provides text-selection functionality for the PDF.
  * It does this by creating overlay divs over the PDF text. These divs
@@ -118,7 +124,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
       var style = styles[geom.fontName];
       var textDiv = document.createElement('div');
       this.textDivs.push(textDiv);
-      if (!/\S/.test(geom.str)) {
+      if (isAllWhitespace(geom.str)) {
         textDiv.dataset.isWhitespace = true;
         return;
       }

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