Re: Hey Karl...
- From: "Bill McCarthy" <TPASoft.com Are Identity Thieves>
- Date: Wed, 8 Apr 2009 14:19:01 +1000
Hi Larry,
"Larry Serflaten" <serflaten@xxxxxxxxxxxxxx> wrote in message news:uwUgzZ3tJHA.3988@xxxxxxxxxxxxxxxxxxxxxxx
"Bill McCarthy" wrote> Having the shorter tests in front should provide for
> quicker iteration through the first items in the list, while having > most
> likely input up front would reduce the number of tests performed.
I doubt that very much. The first test of a string comparison is most
likely to see if the string lengths are the same. If the lengths are the
same then the comparison begins which itself will exit as soon as a buffer
becomes unequal (buffers are sometime optimized to be read as 32 bit on 32
bit systems etc)
That could be,
Well it would be simple enough to test. I would be amazed if the comparison code didn't compare lengths first.
but you did not address the other optimization which was
to put most likely input in front.
Right. That's a different optimisation from the one saying put shorter strings first.
That is just common sense. Its a
trade off, or as I mentioned earlier, its subjective, but it is something
that should be considered when the list grows long.
If you were really serious about optimising that code the first thing it should do is test for the most common strings *without* doing any case changing, eg: check for "true" and "True". But you'd really need to be crunching the parsing for any such optimisation to ever be of any real significance.
.
- References:
- Hey Karl...
- From: Larry Serflaten
- Re: Hey Karl...
- From: Bill McCarthy
- Re: Hey Karl...
- From: Larry Serflaten
- Hey Karl...
- Prev by Date: Re: Searching Folders
- Next by Date: Re: Control Box Control
- Previous by thread: Re: Hey Karl...
- Next by thread: Re: Hey Karl...
- Index(es):
Relevant Pages
|