[D-runtime] dup attributes?
Steve Schveighoffer
schveiguy at yahoo.com
Fri Aug 6 04:06:04 PDT 2010
Well, no, not exactly like that.
The issue is, if you have two void[]'s, and each one has flags associated with
them, the flags of the existing blocks are disregarded. The flags of the void[]
type are used instead.
So something like this:
int[] x = new int[20];
void[] y = x; // y is still the same block, so the NO_SCAN bit is set
y ~= y; // appending preserves bit, so NO_SCAN bit remains set
y = y ~ y; // concatenation ignores the bits of the arguments, so the type is
used to determine bits. y now has the NO_SCAN bit cleared.
y = x; // reset
y = y.dup; // dup ignores current flags, the type is used instead.
-Steve
----- Original Message ----
> From: Sean Kelly <sean at invisibleduck.org>
> To: D's runtime library developers list <d-runtime at puremagic.com>
> Sent: Thu, August 5, 2010 7:15:19 PM
> Subject: Re: [D-runtime] dup attributes?
>
> Concatenation doesn't preserve bit flags? Like if I do this:
>
> mystr ~= "a" ~ "b";
>
> You're saying that it's possible for the bits set on mystr to be lost?
>
> On Aug 4, 2010, at 10:19 AM, Steve Schveighoffer wrote:
>
> > One more thing -- concatenation suffers from the same problem. This one
>might
>
> > be much harder to swallow since you may have to do N flag lookups.
> >
> > -Steve
> >
> >
> >
> > ----- Original Message ----
> >> From: Steve Schveighoffer <schveiguy at yahoo.com>
> >> To: d-runtime <d-runtime at puremagic.com>
> >> Sent: Wed, August 4, 2010 8:32:38 AM
> >> Subject: [D-runtime] dup attributes?
> >>
> >> Currently, in the array runtime code, all appends and length settings copy
>the
>
> >
> >> BlkAttr attributes from the existing block to the new block. This is
> >> important
> >>
> >> if you set block attributes other than the default, or you are appending
>to a
>
> >
> >> block which is currently typed differently than what it was when
>allocated.
> >>
> >> However, the one function which does *not* do this is dup. dup uses the
> >> typeinfo to determine the block attributes, including the NO_SCAN flag.
> >>
> >> I think it should copy the attributes like all the other functions do.
> >> However,
> >>
> >> there is one caveat to this. Currently dup doesn't look up the block
> >> attributes
> >>
> >> of the existing data, because it doesn't have to. So changing dup to copy
>the
>
> >>
> >> attributes would slow down dup a bit because in addition to allocating a
>new
>
> >> block, it must look up the flags for the old block.
> >>
> >> What do you guys think?
> >>
> >> -Steve
> >>
> >>
> >>
> >>
> >> _______________________________________________
> >> D-runtime mailing list
> >> D-runtime at puremagic.com
> >> http://lists.puremagic.com/mailman/listinfo/d-runtime
> >>
> >
> >
> >
> > _______________________________________________
> > D-runtime mailing list
> > D-runtime at puremagic.com
> > http://lists.puremagic.com/mailman/listinfo/d-runtime
>
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
>
More information about the D-runtime
mailing list