[Pkg-javascript-commits] [uglifyjs] 439/491: faster output of comments (#2806)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:52:02 UTC 2018


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

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit cc07f3b806f2a6ea971f290bd44425493f5c2e3d
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Thu Jan 18 02:57:33 2018 +0800

    faster output of comments (#2806)
---
 lib/output.js | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/output.js b/lib/output.js
index 1b1ba2a..805f033 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -451,6 +451,11 @@ function OutputStream(options) {
         return OUTPUT;
     };
 
+    function has_nlb() {
+        var index = OUTPUT.lastIndexOf("\n");
+        return /^ *$/.test(OUTPUT.slice(index + 1));
+    }
+
     function prepend_comments(node) {
         var self = this;
         var start = node.start;
@@ -499,7 +504,7 @@ function OutputStream(options) {
 
         comments = comments.filter(comment_filter, node);
         if (comments.length == 0) return;
-        var last_nlb = /(^|\n) *$/.test(OUTPUT);
+        var last_nlb = has_nlb();
         comments.forEach(function(c, i) {
             if (!last_nlb) {
                 if (c.nlb) {
@@ -546,7 +551,7 @@ function OutputStream(options) {
                 print("\n");
                 indent();
                 need_newline_indented = false;
-            } else if (c.nlb && (i > 0 || !/(^|\n) *$/.test(OUTPUT))) {
+            } else if (c.nlb && (i > 0 || !has_nlb())) {
                 print("\n");
                 indent();
             } else if (i > 0 || !tail) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list