changeset 110:c7f1b4bf6908

Speed up whitespace check in file content
author mr
date Wed, 13 Sep 2017 12:17:17 -0700
parents 023cbafe1425
children b71592d49d67
files jcheck.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/jcheck.py	Mon Aug 21 14:51:04 2017 -0700
+++ b/jcheck.py	Wed Sep 13 12:17:17 2017 -0700
@@ -535,10 +535,11 @@
             fx = ctx.filectx(f)
             if normext_re.match(f) and not self.whitespace_lax:
                 data = fx.data()
-                m = badwhite_re.search(data)
-                if m:
-                    ln = data.count("\n", 0, m.start()) + 1
-                    self.error(ctx, "%s:%d: %s" % (f, ln, badwhite_what(m)))
+                if "\t" in data or "\r" in data or " \n" in data:
+                    m = badwhite_re.search(data)
+                    if m:
+                        ln = data.count("\n", 0, m.start()) + 1
+                        self.error(ctx, "%s:%d: %s" % (f, ln, badwhite_what(m)))
             ## check_file_header(self, fx, data)
             flags = fx.manifest().flags(f)
             if 'x' in flags: