bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fix 'exclude' module to avoid strcasecmp, but with performance probl


From: Bruno Haible
Subject: Re: fix 'exclude' module to avoid strcasecmp, but with performance problems
Date: Thu, 15 Feb 2007 04:27:27 +0100
User-agent: KMail/1.5.4

Paul Eggert wrote:
> However, here I had some performance problems with mbscasemcp.  Given
> two multibyte strings A and B, I want to know whether A is an initial
> prefix of B, ignoring case during comparison; also, if A is a prefix
> of B, I need to know where in B the prefix ends (because I want to
> check that the next char is a '/' in the code below).

Funny: Just yesterday I wrote a module 'mbspcasecmp' for this purpose. The
test modules weren't yet finished, so I could only commit it today.

> This should be an O(N) algorithm, but I don't see an easy way to do
> this with the current mbs* primitives.

You could have done so by using the mbui_* iterator primitives. They
operate on a lower level than the mbs* functions. But with these iterators
you can formulate every algorithm that step through a linear sequence of
characters from left to right, like you would do with pointers. I could
even formulate the Knuth-Morris-Pratt algorithm for substring search in
this setting.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]