Thread overview
Re: String compare performance
Nov 27, 2010
Kagamin
Nov 29, 2010
Stewart Gordon
Nov 29, 2010
bearophobic
Nov 29, 2010
Robert Jacques
November 27, 2010
bearophile Wrote:

> > Also, is there a way to bit-compare given memory areas at much higher speed than element per element (I mean for arrays in general)?
> 
> I don't know. I think you can't.

You can use memcmp, though only for utf-8 strings.
November 29, 2010
On 27/11/2010 23:04, Kagamin wrote:
> bearophile Wrote:
>
>>> Also, is there a way to bit-compare given memory areas at much
>>> higher speed than element per element (I mean for arrays in
>>> general)?
>>
>> I don't know. I think you can't.
>
> You can use memcmp, though only for utf-8 strings.

Only for utf-8 strings?  Why's that?  I would've thought memcmp to be type agnostic.

Stewart.
November 29, 2010
Stewart Gordon Wrote:

> On 27/11/2010 23:04, Kagamin wrote:
> > bearophile Wrote:
> >
> >>> Also, is there a way to bit-compare given memory areas at much higher speed than element per element (I mean for arrays in general)?
> >>
> >> I don't know. I think you can't.
> >
> > You can use memcmp, though only for utf-8 strings.
> 
> Only for utf-8 strings?  Why's that?  I would've thought memcmp to be type agnostic.
> 
> Stewart.

D community is amazing cult of premature optimization fans. Any one of you heard of canonically equivalent sequences? The integrated Unicode support is a clusterfuck. Please do compare ASCII strings with memcmp, but no Unicode. Where did the original poster pull this problem from, his ass? "My system runs 100,000,000,000 instructions per second, but this comparison of 4 letter strings uses 5 cycles too much! This is the only problem on the way to world domination with my $500 Microsoft Word clone!". No wait, the problems are completely imaginatory.

Bye,
bearophobic
November 29, 2010
On Sun, 28 Nov 2010 20:32:24 -0500, Stewart Gordon <smjg_1998@yahoo.com> wrote:

> On 27/11/2010 23:04, Kagamin wrote:
>> bearophile Wrote:
>>
>>>> Also, is there a way to bit-compare given memory areas at much
>>>> higher speed than element per element (I mean for arrays in
>>>> general)?
>>>
>>> I don't know. I think you can't.
>>
>> You can use memcmp, though only for utf-8 strings.
>
> Only for utf-8 strings?  Why's that?  I would've thought memcmp to be type agnostic.
>
> Stewart.

memcmp is type agnostic if all you want to compare is equality. The other use of memcmp is essentially as an opCmp, in which case it would be type sensitive.