Optimize jabber_id_new()

Daniel Atallah daniel.atallah at gmail.com
Tue Jun 30 11:28:45 EDT 2009


On Tue, Jun 30, 2009 at 4:31 AM, Mark Doliner<mark at kingant.net> wrote:
> The jabber_id_new() function in libpurple/protocols/jabber/jutil.c is
> pretty expensive.

<SNIP/>

> How do people feel about me checking this change into the jabber code
> in libpurple?  Meebo probably has a larger percentage of
> English-speaking users than Pidgin, so maybe our results are unfairly
> biased.  Does anyone know how common non-ASCII JIDs are?
>
> I suspect that even for the case where the jid contains non-ASCII
> characters our optimized version won't be very much slower, and might
> even be faster (it makes one pass over the string to determine the
> location of @ and / instead of calling g_utf8_strchr() twice (but
> that's easy to fix on its own)).
>
> In other words: How does everyone feel about the attached patch?

My (completely gut-based) guess is that non-ASCII JIDs are going to be
pretty uncommon "in the wild".  My impression is that even for
non-ASCII languages, people tend to use ASCII transliterations.
Perhaps Peter Saint-Andre can offer some more useful context-specific
insight .

I think the patch looks very reasonable - even in the case where it
ends up having to g_utf8_validate(), the new overhead appears to be
very minimal.

-D




More information about the Devel mailing list