Commit 3e1712bf authored by Stefan Behnel's avatar Stefan Behnel

Avoid string concatenation where we can just compare characters separately.

parent 09628248
...@@ -1149,16 +1149,13 @@ def p_f_string_expr(s, unicode_value, pos, starting_index, is_raw): ...@@ -1149,16 +1149,13 @@ def p_f_string_expr(s, unicode_value, pos, starting_index, is_raw):
"format string cannot include #") "format string cannot include #")
elif nested_depth == 0 and c in '><=!:}': elif nested_depth == 0 and c in '><=!:}':
# allow special cases with '!' and '=' # allow special cases with '!' and '='
if i + 1 < size: if i + 1 < size and c in '!=><':
chars = c + unicode_value[i + 1] if unicode_value[i + 1] == '=':
if chars in ('!=', '==', '>=', '<='): i += 2 # we checked 2, so we can skip 2: '!=', '==', '>=', '<='
i += 2 # we checked 2, so we can skip 2
continue continue
elif c in '><': # allow single '<' and '>'
if c in '><': # allow single '<' and '>'
i += 1 i += 1
continue continue
terminal_char = c terminal_char = c
break break
i += 1 i += 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment