diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-26 14:41:42 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-26 14:41:42 -0400 |
commit | 9deabd31fe51f8bf7dad45c342478878e703605a (patch) | |
tree | bef1f18ce47059f5c4821ec5c7449508736bd29a /coverage/phystokens.py | |
parent | b13796341e7c0f69b58b093aa4a822fefd03ab1b (diff) | |
download | python-coveragepy-9deabd31fe51f8bf7dad45c342478878e703605a.tar.gz |
Micro optimizations.
Diffstat (limited to 'coverage/phystokens.py')
-rw-r--r-- | coverage/phystokens.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/coverage/phystokens.py b/coverage/phystokens.py index 2a91882..f7c099e 100644 --- a/coverage/phystokens.py +++ b/coverage/phystokens.py @@ -1,7 +1,7 @@ """Better tokenizing for coverage.py.""" import codecs, keyword, re, sys, token, tokenize -from coverage.backward import StringIO # pylint: disable=W0622 +from coverage.backward import set, StringIO # pylint: disable=W0622 def phys_tokens(toks): """Return all physical tokens, even line continuations. @@ -18,7 +18,7 @@ def phys_tokens(toks): last_ttype = None for ttype, ttext, (slineno, scol), (elineno, ecol), ltext in toks: if last_lineno != elineno: - if last_line and last_line[-2:] == "\\\n": + if last_line and last_line.endswith("\\\n"): # We are at the beginning of a new line, and the last line # ended with a backslash. We probably have to inject a # backslash token into the stream. Unfortunately, there's more @@ -74,7 +74,7 @@ def source_token_lines(source): is indistinguishable from a final line with a newline. """ - ws_tokens = [token.INDENT, token.DEDENT, token.NEWLINE, tokenize.NL] + ws_tokens = set([token.INDENT, token.DEDENT, token.NEWLINE, tokenize.NL]) line = [] col = 0 source = source.expandtabs(8).replace('\r\n', '\n') |