[Gtk2] About bug 11523: analysis and proper fix(es)
Luiz Americo Pereira Camara
luizmed at oi.com.br
Sun Jul 13 13:38:06 CEST 2008
Mattias Gaertner wrote:
> On Sat, 12 Jul 2008 12:37:17 -0300
> Luiz Americo Pereira Camara <luizmed at oi.com.br> wrote:
>
>>
>>
>> Than i noticed that is not necessary to store the old font and comes
>> with the 2nd implementation. There's also no more need to be a method
>> of TGtk2DeviceContext.
>>
>> 2) Just compare the two strings using StrComp*
>>
>
> That's better.
>
>
>
>> * Is better to use StrLComp instead of StrComp
>>
>> But i lost the shortcut evaluation of length that prevents a string
>> comparation. So...
>>
>> 3) Stores the old length in the layout object using a gquark* and
>> compare both strings with comparebytes (i know that both strings are
>> the same size)
>>
>> ** The old length can be also stored in a field of font GdiObject
>>
>
> Have you compared times?
>
No.
There are two theoretical benefits in 3:
- If the length of the NewText is different from the OldText skip the
string comparation
- CompareBytes is supposed to be faster than StrComp since is hand
optimized (asm) and don't need to check for PChar length/ending
The overhead of storing the oldlength using g_object function can be
removed by storing as a field in the TGDIObject record. I did not tried
that because i don't know the effects of adding an extra field. Also the
function should be modified to receive a font object instead of a pango
layout.
Luiz
More information about the Gtk2
mailing list