From abd07c067ad18b1d7e7e54d615988f4641dc2bb4 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 10 Jun 2015 07:22:33 +0200 Subject: [PATCH] * Inline B and S methods on stateclass --- spacy/syntax/stateclass.pxd | 11 +++++++++-- spacy/syntax/stateclass.pyx | 10 ---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/spacy/syntax/stateclass.pxd b/spacy/syntax/stateclass.pxd index 141c96195..be0380ecb 100644 --- a/spacy/syntax/stateclass.pxd +++ b/spacy/syntax/stateclass.pxd @@ -28,8 +28,15 @@ cdef class StateClass: self._buffer[i] = i return self - cdef int S(self, int i) nogil - cdef int B(self, int i) nogil + cdef inline int S(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 E(self, int i) nogil diff --git a/spacy/syntax/stateclass.pyx b/spacy/syntax/stateclass.pyx index 5b3660a94..4d7cc0fea 100644 --- a/spacy/syntax/stateclass.pyx +++ b/spacy/syntax/stateclass.pyx @@ -21,16 +21,6 @@ cdef class StateClass: self._buffer[i] = i 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: if i < 0 or i >= self.length: return -1