From: Stefan Behnel Date: Thu, 11 Nov 2010 06:24:00 +0000 (+0100) Subject: another minor scanner speed-up X-Git-Tag: 0.14.alpha0~196 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2721708d84705d907e624c6faa6af7cb816a0b2f;p=cython.git another minor scanner speed-up --- diff --git a/Cython/Plex/Scanners.py b/Cython/Plex/Scanners.py index c8519047..02c36a6a 100644 --- a/Cython/Plex/Scanners.py +++ b/Cython/Plex/Scanners.py @@ -163,7 +163,8 @@ class Scanner(object): buffer = self.buffer buf_start_pos = self.buf_start_pos buf_len = len(buffer) - backup_state = None + b_action, b_cur_pos, b_cur_line, b_cur_line_start, b_cur_char, b_input_state, b_next_pos = \ + None, 0, 0, 0, u'', 0, 0 trace = self.trace while 1: if trace: #TRACE# @@ -173,8 +174,8 @@ class Scanner(object): #action = state.action #@slow action = state['action'] #@fast if action is not None: - backup_state = ( - action, cur_pos, cur_line, cur_line_start, cur_char, input_state, next_pos) + b_action, b_cur_pos, b_cur_line, b_cur_line_start, b_cur_char, b_input_state, b_next_pos = \ + action, cur_pos, cur_line, cur_line_start, cur_char, input_state, next_pos # End inlined self.save_for_backup() c = cur_char #new_state = state.new_state(c) #@slow @@ -234,9 +235,11 @@ class Scanner(object): if trace: #TRACE# print("blocked") #TRACE# # Begin inlined: action = self.back_up() - if backup_state is not None: - (action, cur_pos, cur_line, cur_line_start, - cur_char, input_state, next_pos) = backup_state + if b_action is not None: + (action, cur_pos, cur_line, cur_line_start, + cur_char, input_state, next_pos) = \ + (b_action, b_cur_pos, b_cur_line, b_cur_line_start, + b_cur_char, b_input_state, b_next_pos) else: action = None break # while 1