std.uuid: Update 4
Johannes Pfau
nospam at example.com
Sun Jun 17 01:04:28 PDT 2012
Am Sat, 16 Jun 2012 21:11:51 +0400
schrieb Dmitry Olshansky <dmitry.olsh at gmail.com>:
> On 16.06.2012 21:06, Dmitry Olshansky wrote:
> > On 16.06.2012 15:30, Johannes Pfau wrote:
> >> Am Tue, 12 Jun 2012 13:46:17 +0200
> >> schrieb Johannes Pfau<nospam at example.com>:
> >>
> >>> Am Mon, 11 Jun 2012 13:12:49 +0200
> >>> schrieb Johannes Pfau<nospam at example.com>:
> >>>
> >>>> Am Sun, 10 Jun 2012 18:49:03 +0200
> >>>> schrieb Johannes Pfau<nospam at example.com>:
> >>>>
> >>>>> Am Sat, 09 Jun 2012 21:30:57 +0400
> >>>>> schrieb Dmitry Olshansky<dmitry.olsh at gmail.com>:
> >>>>>> Code: https://github.com/jpf91/phobos/blob/std.uuid/std/uuid.d
> >>>>>> API-Docs: http://dl.dropbox.com/u/24218791/d/src/uuid.html
> >>>>>
> >>>>> I pushed these changes suggested by Dmitry Olshansky and Jonas
> >>>>> Drewsen:
> >>>>>
> >>>>> * Add documentation table
> >>>>> * Rename UUID.isNil --> UUID.empty
> >>>>> * Merge ParserException and IsufficientInputException into
> >>>>> UUIDParserException
> >>>>> * Add note about std.variant.Variant
> >>>>> * Rewrite example to avoid cast
> >>>>> * Add non-working(commented out) variadic constructor
> >>>>> * Rename extractRegex --> uuidRegex
> >>>>> * Use std.algorithm.swap instead of swapRanges
> >>>>
> >>>> * parseUUID now supports InputRanges with ElementType == dchar
> >>>> (all string types are still supported as well)
> >>>>
> >>>>
> >>>
> >>> * randomUUID now creates the RNG only once per thread.
> >>> * randomUUID lazily seeds the RNG once (per thread) on the first
> >>> function call
> >>> * randomUUID now uses the new seed overload (requires
> >>> https://github.com/D-Programming-Language/phobos/pull/627 )
> >>> * the unsafe randomUUID overload taking only a type has been
> >>> removed.
> >>>
> >>
> >> * Add changes suggested by Jonathan M Davis (see
> >> https://github.com/jpf91/phobos/commit/91cd1c1f4385cfe1cd868c0720aff257d9436822
> >>
> >> )
> >
> > Surely, a better way then making a global is to routinely check for
> > zeros.
> >
> > Plus, you can cast .ptr to size_t* and compare word by word in 4 or
> > 2 ops(!). You'd better watch out for __ctfe though, it deon't allow
> > casting pointers this way.
> >
> >
>
> Ah and another way to go about it is:
> union {
> ubyte[16] uuid;
> size_t[16/size_t.sizeof] by_word;
> }
>
Isn't that an optimization which should really be done by the compiler?
It already knows that it's supposed to compare two ubyte[16]...
Also how could the union solution be used without having to copy the
data?
More information about the Digitalmars-d
mailing list