in reply to Re: Common Substrings
in thread Common Substrings

Thanks!

It took me a bit to understand that you were using a bisection method. But I agree that it should be reasonably efficient. I just have a tendency to avoid substr() since it always feels like a very expensive call.

The strings that I am spliting are paths, and because my sub then looks for the place of a slash, which should be 8 bits, I think that it is safe for me to use a binary method.

Replies are listed 'Best First'.
Re^3: Common Substrings
by salva (Canon) on Nov 15, 2005 at 11:51 UTC
    I just have a tendency to avoid substr() since it always feels like a very expensive call.

    substr is actually quite cheap as it doesn't copy the char data from the the original string, it just makes an alias to it.

    The strings that I am spliting are paths, and because my sub then looks for the place of a slash, which should be 8 bits

    I don't think so, on UTF8 strings byte offsets and char offsets can be different!