What could have been the reason for this?

Phil Edwards phil@jaj.com
Mon Jun 10 06:58:00 GMT 2002


On Mon, Jun 03, 2002 at 11:31:13PM +0000, Nathan Myers wrote:
> > What would SGI have gained by using this extra copy?  I don't see any
> > difficulties that would require the proverbial extra level of indirection.
> > Am I overlooking some design decision?
> 
> No doubt there was some case where somebody was inserting a value that
> was already in the array, but either (1) it appears at a higher index
> than the insertion point, so that shifting elements down blows away the 
> argument instance before there is a place to put the copy, or (2) the
> insertion needs a reallocation, and the old copy gets destroyed before
> they get around to copying it into place.  Rather than detect those 
> cases and handle them, they just made another copy first.

Ah.  Ugh.

> It's decidedly suboptimal for objects that have nontrivial copy
> semantics.  You can optimize this by using less<T*> to detect 
> whether the argument reference is actually in the array.  You 
> take a pointer to the argument, and then adjust the pointer if 
> the target actually moves out from under it.

I'm going to try and think of a better way than this.  Maybe.


> > One of my favorite hard science fiction novels involves a society of
> > spacefaring traders.  Their ships' libraries have accumulated thousands
> > of years worth of software.  As a result, the most needed job on any
> > trading ship is "Programmer-Archaeologist," someone who can dig through
> > the centuries of code.  I'm beginning to sympathize.  :-)
> 
> That's Vernor Vinge.  If you haven't read "The Peace War" yet, you are
> missing out on fundamental juju.

Dayton, Ohio is a wasteland when it comes to good bookstores carrying good
science fiction.  It took me months to find a copy of "A Deepness in The
Sky" even when it was fresh and popular.  I can't find any Gene Wolfe either.


Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams



More information about the Libstdc++ mailing list