[Fwd: too much copy in map]
Jeremy G. Siek
jsiek@cthulhu.engr.sgi.com
Sat Apr 1 00:00:00 GMT 2000
Levente Farkas wrote:
>
> "Jeremy G. Siek" wrote:
> >
> > And BTW, the !spam thing in your return address is annoying.
>
> what's more annoying when the email collecting robots find my email
> address and than send me spam. anyway if you are using a good mailer
> than it's not a problem since my Reply-to: is set to the correct
> address and if you press reply the good address will punt into the
> To: line.
Your previous emails did not have a Reply-to: line.
> I thing it's better to optimize code by hand if possible.
Try timing it with optimization turned on.
> anyway your example is wrong. you can't set v.first, since it's
> a const int and that's the reason (since pair has no constructor
> which inicialize just, the first) why we have to call to copy in
Good point.
> the this implementation. but operator[] can be implement without
> this extra copy, without hurt the standard (but the other insert
> can't).
>
> > probably shouldn't put a large object directly into the map... instead
> > store pointers in the map and define a custom compare operator.
>
> I thing the best way to avoid all memory management in a code, but
> (unfortunately) in this case stl always copy (sometimes more than
> necessary).
How about putting the objects in a vector (and pointers or indices
into the vector in the map). Of course you may find this indirection
causes more slow down than the extra copy.
--
------------------------------------------------------------------------
Jeremy Siek email: jsiek@engr.sgi.com
Ph.D. Candidate cell-phone: (415) 377-5814
Univ. of Notre Dame phone: (650) 933-8724
C++ Library & Compiler Group fax: (650) 932-0127
Silicon Graphics Inc. www: http://www.lsc.nd.edu/~jsiek/
------------------------------------------------------------------------
More information about the Libstdc++
mailing list