Leopold Toetsch wrote: > To improve this (and some other operations like this) further, it would > be nice, if we could combine encoding->decode and encoding->skip_forward > to another function: > > INTVAL code = s->encoding->decode_skip_forward_1( &sptr );
I would prefer this to be done via an iterator, as it would also solve the skip_backward problems with DBCS encoding. Something like: typedef struct string_iterator_t { String *str; UINTVAL bytepos; UINTVAL charpos; UINTVAL (*decode_and_advance)(struct string_iterator_t *i); } string_iterator; Then in hash.c the code would be something like: struct string_iterator_t i1; struct string_iterator_t i2; string_iterator_init(&i1, s1); string_iterator_init(&i2, s2); while (len--) { if (i1.decode_and_advance(&i1) != i2.decode_and_advance(&i2)) return 1; } return 0; For the hash_utf8 benchmark with the current code I get numbers like: 3.758691 5.535916 With the above iterator code (and the UTF8 decode_and_advance function implemented) I get: 3.757812 4.844776 Does anybody think this is worth implementing? Regards Peter Gibbs EmKel Systems