Commit ff067a8f authored by Stefan Behnel's avatar Stefan Behnel

reduced overhead in the scanner

parent d472191c
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
#======================================================================= #=======================================================================
import cython import cython
cython.declare(BOL=object, EOL=object, EOF=object) cython.declare(BOL=object, EOL=object, EOF=object, NOT_FOUND=object)
import Errors import Errors
from Regexps import BOL, EOL, EOF from Regexps import BOL, EOL, EOF
NOT_FOUND = object()
class Scanner(object): class Scanner(object):
""" """
A Scanner is used to read tokens from a stream of characters A Scanner is used to read tokens from a stream of characters
...@@ -179,8 +181,8 @@ class Scanner(object): ...@@ -179,8 +181,8 @@ class Scanner(object):
# End inlined self.save_for_backup() # End inlined self.save_for_backup()
c = cur_char c = cur_char
#new_state = state.new_state(c) #@slow #new_state = state.new_state(c) #@slow
new_state = state.get(c, -1) #@fast new_state = state.get(c, NOT_FOUND) #@fast
if new_state == -1: #@fast if new_state is NOT_FOUND: #@fast
new_state = c and state.get('else') #@fast new_state = c and state.get('else') #@fast
if new_state: if new_state:
if trace: #TRACE# if trace: #TRACE#
......
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