2014-10-23 19:23:42 +04:00
|
|
|
from preshed.maps cimport PreshMap
|
|
|
|
from cymem.cymem cimport Pool
|
2014-12-03 03:06:00 +03:00
|
|
|
from murmurhash.mrmr cimport hash64
|
2014-10-23 19:23:42 +04:00
|
|
|
|
|
|
|
from .typedefs cimport utf8_t, id_t, hash_t
|
|
|
|
|
|
|
|
|
|
|
|
cdef struct Utf8Str:
|
|
|
|
id_t i
|
|
|
|
hash_t key
|
|
|
|
utf8_t chars
|
|
|
|
int length
|
|
|
|
|
|
|
|
|
2014-12-03 03:06:00 +03:00
|
|
|
cdef struct UniStr:
|
|
|
|
Py_UNICODE* chars
|
|
|
|
size_t n
|
|
|
|
hash_t key
|
|
|
|
|
|
|
|
|
|
|
|
cdef inline void slice_unicode(UniStr* s, Py_UNICODE* chars, int start, int end) nogil:
|
|
|
|
s.chars = &chars[start]
|
|
|
|
s.n = end - start
|
|
|
|
s.key = hash64(s.chars, s.n * sizeof(Py_UNICODE), 0)
|
|
|
|
|
|
|
|
|
2014-10-23 19:23:42 +04:00
|
|
|
cdef class StringStore:
|
|
|
|
cdef Pool mem
|
2014-12-02 17:33:20 +03:00
|
|
|
cdef PreshMap _map
|
2014-10-23 19:23:42 +04:00
|
|
|
cdef Utf8Str* strings
|
|
|
|
cdef int size
|
|
|
|
cdef int _resize_at
|
|
|
|
|
2014-12-03 08:01:47 +03:00
|
|
|
cdef const Utf8Str* intern(self, char* chars, int length) except NULL
|