summaryrefslogtreecommitdiff
path: root/coverage/phystokens.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-10-26 14:41:42 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-10-26 14:41:42 -0400
commitc2e4447f84b7d5f1056e367b094f82065aaaff59 (patch)
tree822b40ecabfa9863c7cd562641168061297e8ec6 /coverage/phystokens.py
parent191f41f43a2933ac921847f877d87c2594d727f0 (diff)
downloadpython-coveragepy-git-c2e4447f84b7d5f1056e367b094f82065aaaff59.tar.gz
Micro optimizations.
Diffstat (limited to 'coverage/phystokens.py')
-rw-r--r--coverage/phystokens.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/coverage/phystokens.py b/coverage/phystokens.py
index 2a91882d..f7c099ef 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')