Review Request: little faster sycoca

Jaime jtamate at gmail.com
Thu Sep 29 07:46:20 BST 2011


2011/9/28 Rolf Eike Beer <kde at opensource.sf-tec.de>:
> Am Mittwoch, 28. September 2011, 15:47:25 schrieb Josef Weidendorfer:
>> On Wednesday 28 September 2011, Jaime Torres Amate wrote:
>
>> > and the removal of a for loop (I'm checking it this has been this way
>> > since the beginning, or if fixing it makes other things faster) as Rolf
>> > has pointed.
>>
>> I do not see how that loop can be removed. He probably misread the inner
>> condition of the first loop as "if (pos < 1 ", but it is actually

I did misread it. :-(

With my latest version (tested yesterday with very success), this
scenario changes.
I can commit version 2 (approved by David) or version 3 of the patch (waiting).

By the way, a simple workaround for my problems with mimetype
inode/directory is to
modify the environment variable XDG_DATADIRS to include also
/usr/local/share:/usr/share.
But I'll check why they are not processed only with XDG_DATADIRS=/opt/kde4/share

>> "if (pos < entry.length", and pos can be any position in the string.
>
> I meant this:
>
>    if (inPos < 0) {
>        pos = -inPos-1;
>        for(KSycocaDictStringList::const_iterator it = stringlist-
>>constBegin(); it != stringlist->constEnd(); ++it)
>        {
>            string_entry* entry = *it;
>            register int l = entry->length;
>            if (pos < l && pos != 0) {
>                ...
>            }
>        }
>
> What happens if inPos is -1? pos becomes 0 then. Then we iterate over the
> whole list just to do "if (... && pos != 0)" which will never be true. So for
> this case (inPos == -1) the whole function can be avoided at all as it will
> never return anything else but 0. So the initial check of the function should
> IMHO be:
>
>    if (inPos == 0 || inPos == -1)
>        return 0;
>
> Eike




More information about the kde-core-devel mailing list