From: Stefan Behnel Date: Mon, 15 Nov 2010 21:02:36 +0000 (+0100) Subject: reduced overhead in the scanner X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ff067a8f5a22f7becfdec996eb5b46913bbac81e;p=cython.git reduced overhead in the scanner --- diff --git a/Cython/Plex/Scanners.py b/Cython/Plex/Scanners.py index 02c36a6a..d2fa468c 100644 --- a/Cython/Plex/Scanners.py +++ b/Cython/Plex/Scanners.py @@ -8,11 +8,13 @@ #======================================================================= import cython -cython.declare(BOL=object, EOL=object, EOF=object) +cython.declare(BOL=object, EOL=object, EOF=object, NOT_FOUND=object) import Errors from Regexps import BOL, EOL, EOF +NOT_FOUND = object() + class Scanner(object): """ A Scanner is used to read tokens from a stream of characters @@ -179,8 +181,8 @@ class Scanner(object): # End inlined self.save_for_backup() c = cur_char #new_state = state.new_state(c) #@slow - new_state = state.get(c, -1) #@fast - if new_state == -1: #@fast + new_state = state.get(c, NOT_FOUND) #@fast + if new_state is NOT_FOUND: #@fast new_state = c and state.get('else') #@fast if new_state: if trace: #TRACE#