From d7952634cae783948b7f81543c37ec583a9a9d67 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 3 Dec 2014 16:01:47 +1100 Subject: [PATCH] * Make the string-store serve const pointers to Utf8Str --- spacy/utf8string.pxd | 2 +- spacy/utf8string.pyx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/utf8string.pxd b/spacy/utf8string.pxd index 6bd5c6757..5ef4113d5 100644 --- a/spacy/utf8string.pxd +++ b/spacy/utf8string.pxd @@ -31,4 +31,4 @@ cdef class StringStore: cdef int size cdef int _resize_at - cdef Utf8Str* intern(self, char* chars, int length) except NULL + cdef const Utf8Str* intern(self, char* chars, int length) except NULL diff --git a/spacy/utf8string.pyx b/spacy/utf8string.pyx index 0384a150c..1d2b7a264 100644 --- a/spacy/utf8string.pyx +++ b/spacy/utf8string.pyx @@ -20,7 +20,7 @@ cdef class StringStore: def __getitem__(self, object string_or_id): cdef bytes byte_string - cdef Utf8Str* utf8str + cdef const Utf8Str* utf8str if isinstance(string_or_id, int) or isinstance(string_or_id, long): if string_or_id < 1 or string_or_id >= self.size: raise IndexError(string_or_id) @@ -36,7 +36,7 @@ cdef class StringStore: else: raise TypeError(type(string_or_id)) - cdef Utf8Str* intern(self, char* chars, int length) except NULL: + cdef const Utf8Str* intern(self, char* chars, int length) except NULL: # 0 means missing, but we don't bother offsetting the index. We waste # slot 0 to simplify the code, because it doesn't matter. assert length != 0