From 7d239df4c853594aaa50c52c4fb2f444bfd93630 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 13 Sep 2014 00:31:53 +0200 Subject: [PATCH] * Fiddle with declarations, for small efficiency boost --- spacy/lang.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/lang.pyx b/spacy/lang.pyx index 6f8a13f6e..6951e8a87 100644 --- a/spacy/lang.pyx +++ b/spacy/lang.pyx @@ -119,6 +119,7 @@ cdef class Language: cdef uint64_t hashed = string.key cdef size_t first_token = tokens.length + cdef int split cdef int remaining = string.n cdef String prefix while remaining >= 1: @@ -232,14 +233,13 @@ cdef void string_from_unicode(String* s, unicode uni): string_from_slice(s, uni, 0, len(uni)) -cdef void string_from_slice(String* s, Py_UNICODE* chars, size_t start, size_t end): +cdef inline void string_from_slice(String* s, Py_UNICODE* chars, size_t start, size_t end) nogil: s.chars = &chars[start] s.n = end - start s.key = hash64(s.chars, s.n * sizeof(Py_UNICODE), 0) -cdef void string_slice_prefix(String* s, String* prefix, size_t n): - assert s.n >= n +cdef inline void string_slice_prefix(String* s, String* prefix, size_t n) nogil: string_from_slice(prefix, s.chars, 0, n) s.chars += n s.n -= n