Re: Fastcode CompareStr B&V 1.1



I noticed the special case that Pierre has optimized for too. A great catch
to be sure. I admit that it never even crossed my mind.

As to the "real world", it is hard to say. The things my applications seem
to compare (alpha-numeric product numbers for example) don't have a lot of
variation in the highest order character, but I'm not sure that can be
extrapolated to the general use of this function. Hopefully others will
chime in and lend their experiences.

Best Regards,
Eric


"Dennis" <marianndkc@xxxxxxxxxxxxxxx> wrote in message
news:43216f4c$1@xxxxxxxxxxxxxxxxxxxxxxxxx
> Hi Pierre, Eric etc.
>
> I am interested in what makes Pierre's functions so much faster than mine.
> It looks to me as the first algorithm tweak he uses is to take advantage
> of
> the fact that all non-nil AnsiStrings contains one character, namely the
> zero terminator. Then you can compare first chars without reading the
> string
> lengths first. Many of the strings in the benchmark are different in the
> first char and your algorithm becomes very fast in these cases. I totally
> missed this possible optimization when I wrote my functions ;-)
>
> Is this correctly noticed by me?
>
> Is the amount of strings in the benchmark that are different in the first
> char realistic compared to strings that are compared in the real world?
>
> Best regards
> Dennis
>
>


.



Relevant Pages

  • Re: tkFileDialog question
    ... If you want to compare *identity*, to see if two results refer to the very same object or not, use `is` or `is not` ... (In your example, it *may* appear to work, because CPython optimizes very short strings like 'a' or '', but you should not rely on this optimization) ... Gabriel Genellina ...
    (comp.lang.python)
  • Re: Results of the memswap() smackdown from the thread "Sorting" assignment
    ... you used small strings for a reason. ... (but not as good as Ben's optimization) ... relying on the quality of whatever library does memcpy while at the ... a way that I can redefine any library function by a macro. ...
    (comp.programming)
  • Re: A note on computing thugs and coding bums
    ... Here's my response including a bug fix. ... to make "modern strings" possible was designed and first implemented ... contents to strings, to compare them, and to duplicate them. ... while the Pike code will NEVER work...for international strings. ...
    (comp.programming)
  • Re: Ascan with a Substr
    ... the above suggestion: ... operator to compare the strings. ... code block you originally used was just right, ...
    (comp.lang.clipper)
  • Re: Ascan with a Substr
    ... The following solution work well ... operator to compare the strings. ... code block you originally used was just right, ...
    (comp.lang.clipper)