Commits

Mikhail Korobov committed 5186042

Faster CompletionDAWG.keys() method + str/unicode fixes

Comments (0)

Files changed (1)

 
     cpdef list keys(self, unicode prefix=""):
         cdef bytes b_prefix = prefix.encode('utf8')
-        cdef bytes key
+        cdef unicode key
         cdef BaseType index = self.dct.root()
         cdef list res = []
 
         try:
             completer.Start(index, b_prefix)
             while completer.Next():
-                key = completer.key()
-                res.append(key.decode('utf8'))
+                key = (<char*>completer.key()).decode('utf8')
+                res.append(key)
 
         finally:
             del completer
     cpdef list items(self, unicode prefix=""):
         cdef bytes b_prefix = prefix.encode('utf8')
         cdef bytes value, b_value
-        cdef str u_key
+        cdef unicode u_key
         cdef int i
         cdef list res = []
         cdef char* raw_key
 
     cpdef list keys(self, unicode prefix=""):
         cdef bytes b_prefix = prefix.encode('utf8')
-        cdef str u_key
+        cdef unicode u_key
         cdef int i
         cdef list res = []
         cdef char* raw_key