On Wed, Nov 7, 2018 at 12:59 AM Tony V E <
tvan...@gmail.com> wrote:
> On Tue, Nov 6, 2018 at 5:23 AM Andrey Semashev <
andrey....@gmail.com> wrote:
>>
>> On 11/6/18 11:23 AM, Joel FALCOU wrote:
>> > If boost::uuid is enough and has a compelling argument, then maybe
>> > that's what need to be standardized.
>> > Boost provided maybe 80% of the new C++11 library, I can't see why we
>> > can't continue pulling interesting piece of boost that
>> > shown efficiency and proper interface to solve a problem instead of
>> > consuming more man-time.
>>
>> There are some downsides of Boost.UUID that I'm not happy with and that
>> this proposal may fix. In particular, Boost.UUID mandates uuid internal
>> implementation as an array of bytes, which prevents some optimizations.
>
> Sorry to ask you to repeat things that we've mentioned before, but where do these optimizations happen?
> IIUC:
>
> - == and != can be same speed regardless of order ? (ie you could compare it as int128 or whatever)
Yes.
> - < can't be fast if we use the ordering defined in the spec, but could be if it was just "some order" (ie again, read the bytes as an in128, ignoring byte order differences)
Yes, ordering (i.e. operator<) is the main concern. I think, the
ordering behavior (i.e., that the operator< implements lexicographical
or other defined ordering) could be useful for interoperation between
implementations. For example, if you serialize an ordered sequence of
UUIDs in one program, you can be sure that it is ordered the same way
in any other program, built with another implementation. I'm not sure
how useful that would be, but it's worth considering, IMHO.
> - we could have < be slow, but offer a fast_uuid_order for use in maps?
I really don't like the idea of having special ordering predicates
because it will just be too complicated and obscure to use and
ultimately noone will care to use them. If you have the fast one, why
is it not the default? Besides, function objects are not always
convenient to use, e.g. when you have to write a composite predicate
or otherwise have to spell the comparison in a function body. No, just
allow for the most optimal implementation of operator< and let the
other machinery, like std::default_order, do its regular job.
Besides ordering, string operations could be optimized with SIMD as
well, and having a mandatory internal representation could penalize
that.