@@ -106,7 +106,6 @@ include "includes.pxi"
106106
107107import re
108108import sys
109- import array
110109import warnings
111110
112111
@@ -404,23 +403,22 @@ cdef utf8indices(char * cstring, int size, int *pos, int *endpos):
404403 endpos[0 ] = newendpos
405404
406405
407- cdef array.array unicodeindices(array.array positions,
406+ cdef void unicodeindices(map [ int , int ] & positions,
408407 char * cstring, int size, int * cpos, int * upos):
409- """ Convert an array of UTF-8 byte indices to unicode indices."""
408+ """ Convert UTF-8 byte indices to unicode indices."""
410409 cdef unsigned char * s = < unsigned char * > cstring
411- cdef int i = 0
412- cdef array.array result = array.clone(positions, len (positions), False )
413-
414- if positions.data.as_longs[i] == - 1 :
415- result.data.as_longs[i] = - 1
416- i += 1
417- if i == len (positions):
418- return result
419- if positions.data.as_longs[i] == cpos[0 ]:
420- result.data.as_longs[i] = upos[0 ]
421- i += 1
422- if i == len (positions):
423- return result
410+ cdef map [int , int ].iterator it = positions.begin()
411+
412+ if dereference(it).first == - 1 :
413+ dereference(it).second = - 1
414+ postincrement(it)
415+ if it == positions.end():
416+ return
417+ if dereference(it).first == cpos[0 ]:
418+ dereference(it).second = upos[0 ]
419+ postincrement(it)
420+ if it == positions.end():
421+ return
424422
425423 while cpos[0 ] < size:
426424 if s[cpos[0 ]] < 0x80 :
@@ -442,12 +440,11 @@ cdef array.array unicodeindices(array.array positions,
442440 upos[0 ] += 1
443441 emit_endif()
444442
445- if positions.data.as_longs[i] == cpos[0 ]:
446- result.data.as_longs[i] = upos[0 ]
447- i += 1
448- if i == len ( positions):
443+ if dereference(it).first == cpos[0 ]:
444+ dereference(it).second = upos[0 ]
445+ postincrement(it)
446+ if it == positions.end( ):
449447 break
450- return result
451448
452449
453450__all__ = [
0 commit comments