Re: Faster UTF-8 decoding in GLib



Hi again,

Am Dienstag, den 16.03.2010, 18:47 +0200 schrieb Daniel Elstner:
> Am Dienstag, den 16.03.2010, 17:20 +0200 schrieb Mikhail Zabaluev:
>
> > The new code uses a table of unrolled functions to decode byte
> > sequences, dispatched by the first character. g_utf8_get_char() got an
> > inlined implementation.
> 
> Ouch.  I'm not sure that's such a great idea -- indirect calls usually
> completely kill any branch prediction.  I would advise to test on
> different CPU types.  Also, table lookups have their downside -- more
> cache pressure, GOT needs to be fetched etc.

    static inline gunichar
    g_utf8_get_char_fast (const gchar *p)
    {
      const guchar *up = (const guchar *) p;
      return g_utf8_getter_table[up[0]] (up);
    }

Also, do you realize that have just single-handedly introduced 256 (!)
address references that need to be resolved by the dynamic linker at
library load time? :-D

--Daniel




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