Boost logo

Boost :

Subject: Re: [boost] [uuids] On boost::uuids::uuid operator == performance.
From: Peter Dimov (pdimov_at_[hidden])
Date: 2012-04-16 11:16:28

Michael Kochetkov wrote:
> int main() {
> uint8_t d1[16], d2[16];
> return memcmp(d1,d2,16);
> }
> Here is the result.
> $LL4_at_main:
> mov esi, DWORD PTR [edx]
> cmp esi, DWORD PTR [ecx]
> jne SHORT $LN5_at_main
> sub eax, 4
> add ecx, 4
> add edx, 4
> cmp eax, 4
> jae SHORT $LL4_at_main
> xor eax, eax
> Pretty neat.

That's not what I see for the following:

int main()
    boost::uuids::uuid id1, id2;
    return memcmp(,, 16 );

even though uuid::data is uint8_t[16]. I see an assembly listing that is
virtually identical to the one you posted for _Equal, which is also just a
memcmp call:

inline bool __CLRCALL_OR_CDECL _Equal(const unsigned char *_First1,
    const unsigned char *_Last1, const unsigned char *_First2,
    random_access_iterator_tag, _Range_checked_iterator_tag)
    { // compare [_First1, _Last1) to [First2, ...), for unsigned chars
    _DEBUG_RANGE(_First1, _Last1);
    if (_First1 != _Last1)

    return (::memcmp(_First1, _First2, _Last1 - _First1) == 0);

I'm using VC++2005 though.

Although in both cases, the loop that is actually executed is identical to
the one you give above.

Boost list run by bdawes at, gregod at, cpdaniel at, john at