* Inline B and S methods on stateclass

This commit is contained in:
Matthew Honnibal 2015-06-10 07:22:33 +02:00
parent e2f9a80713
commit abd07c067a
2 changed files with 9 additions and 12 deletions

View File

@ -28,8 +28,15 @@ cdef class StateClass:
self._buffer[i] = i self._buffer[i] = i
return self return self
cdef int S(self, int i) nogil cdef inline int S(self, int i) nogil:
cdef int B(self, int i) nogil if i >= self._s_i:
return -1
return self._stack[self._s_i - (i+1)]
cdef inline int B(self, int i) nogil:
if (i + self._b_i) >= self.length:
return -1
return self._buffer[self._b_i + i]
cdef int H(self, int i) nogil cdef int H(self, int i) nogil
cdef int E(self, int i) nogil cdef int E(self, int i) nogil

View File

@ -21,16 +21,6 @@ cdef class StateClass:
self._buffer[i] = i self._buffer[i] = i
self._empty_token.lex = &EMPTY_LEXEME self._empty_token.lex = &EMPTY_LEXEME
cdef int S(self, int i) nogil:
if i >= self._s_i:
return -1
return self._stack[self._s_i - (i+1)]
cdef int B(self, int i) nogil:
if (i + self._b_i) >= self.length:
return -1
return self._buffer[self._b_i + i]
cdef int H(self, int i) nogil: cdef int H(self, int i) nogil:
if i < 0 or i >= self.length: if i < 0 or i >= self.length:
return -1 return -1