diff options
author | hhsprings <xwhhsprings@gmail.com> | 2015-11-07 21:59:57 +0900 |
---|---|---|
committer | hhsprings <xwhhsprings@gmail.com> | 2015-11-07 21:59:57 +0900 |
commit | 4d5ef3c7733a6667cc083f0dbab042be556daab9 (patch) | |
tree | d645a9092949965347948d573ca0c066ff4190d8 | |
parent | b9b77fbceb32da2b4973725a4bda356535429424 (diff) | |
download | pygments-4d5ef3c7733a6667cc083f0dbab042be556daab9.tar.gz |
See `#1164 <https://bitbucket.org/birkenfeld/pygments-main/issues/1164/linter-to-check-for-single-character#comment-23138389>`_.
Before:
28807 bytes, 118.3000 [ms] / 0.004107 [ms/byte]
30964 bytes, 130.4700 [ms] / 0.004214 [ms/byte]
159 bytes, 1.2000 [ms] / 0.007547 [ms/byte]
28807 bytes, 117.6800 [ms] / 0.004085 [ms/byte]
30964 bytes, 124.3500 [ms] / 0.004016 [ms/byte]
159 bytes, 0.9500 [ms] / 0.005975 [ms/byte]
28807 bytes, 123.9600 [ms] / 0.004303 [ms/byte]
30964 bytes, 124.1700 [ms] / 0.004010 [ms/byte]
159 bytes, 1.3200 [ms] / 0.008302 [ms/byte]
After:
28807 bytes, 11.3200 [ms] / 0.000393 [ms/byte]
30964 bytes, 21.6200 [ms] / 0.000698 [ms/byte]
159 bytes, 0.3400 [ms] / 0.002138 [ms/byte]
28807 bytes, 15.8100 [ms] / 0.000549 [ms/byte]
30964 bytes, 21.6800 [ms] / 0.000700 [ms/byte]
159 bytes, 0.4100 [ms] / 0.002579 [ms/byte]
28807 bytes, 11.4300 [ms] / 0.000397 [ms/byte]
30964 bytes, 15.3000 [ms] / 0.000494 [ms/byte]
159 bytes, 0.3900 [ms] / 0.002453 [ms/byte]
About x10 faster...
-rw-r--r-- | pygments/lexers/diff.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pygments/lexers/diff.py b/pygments/lexers/diff.py index 9efb100b..2056fbff 100644 --- a/pygments/lexers/diff.py +++ b/pygments/lexers/diff.py @@ -136,10 +136,12 @@ class WDiffLexer(RegexLexer): ins_cl = r"\+\}" del_op = r"\[\-" del_cl = r"\-\]" + normal = r'[^{}[\]+-]+' # for performance tokens = { 'root': [ (ins_op, Generic.Inserted, 'inserted'), (del_op, Generic.Deleted, 'deleted'), + (normal, Text), (r'.', Text), ], 'inserted': [ @@ -148,6 +150,7 @@ class WDiffLexer(RegexLexer): (del_cl, Generic.Inserted, '#pop'), (ins_cl, Generic.Inserted, '#pop'), + (normal, Generic.Inserted), (r'.', Generic.Inserted), ], 'deleted': [ @@ -156,6 +159,7 @@ class WDiffLexer(RegexLexer): (ins_cl, Generic.Deleted, '#pop'), (del_cl, Generic.Deleted, '#pop'), + (normal, Generic.Deleted), (r'.', Generic.Deleted), ], } |