Re: g_strjoinv() is very slow

David Odin wrote:

>     OK. Thanks for all your comments.
>  I've attached a new version which takes all your remarks in account.

OK, just to point something out, all those for (int i = 1; array[i] != NULL;
i++) and whatnot's in the for loops should be something like

for (char *c = str + 1; *c != 0; c ++)
That way, you don't have to do an index lookup on every iteration... it'll
speed the code up a lot (one less multiplication per iteration).

That's how functions like these are coded in the various incarnations of
libc, too.  Never use an index value to an array when a pointer to the value
is usable.  If you need to find the actual index value from the start of an
array, you can use (c - str), which is one subtraction per loop, which is
still faster than a multiplication.

I don't know if any of this makes any difference, but seeing how the thread
subject is complaining about speed issues, I thought I might mention this.
Being a game programmer, I'm rather used to doing everything possible for
even the slightest speed increase... ~,^

Sean, Etc.

>         Best regards,
>                    DindinX
> --
> David Odin bigfoot com
> If Bill Gate$ had a nickel for every time window$ crashed...
>  ... oh, wait, he does...
>   ------------------------------------------------------------------------
>    diff.glibName: diff.glib
>             Type: Plain Text (text/plain)

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