Hi ROOTers, Currently (ROOT 3.02/03) the read part of an automatically generated streamer contains for reading of a STL vector code like fCoeff.clear(); int R__i, R__n; R__b >> R__n; for (R__i = 0; R__i < R__n; R__i++) { double R__t; R__b >> R__t; fCoeff.push_back(R__t); } This works, but can cause an unnecessary amount of reallocations of the vector. Since the number of elements to be inserted is known up front this can be avoided by requesting enough capacity before the elements are inserted by calling the reserve() method ahead of time, like in fCoeff.clear(); int R__i, R__n; R__b >> R__n; fCoeff.reserve(R__n); for (R__i = 0; R__i < R__n; R__i++) { ... as before ... This ensures that at most one reallocation is done when a vector is read. Only vectors and strings provide capacity management, so in practice this is only relevant for STL vectors and can't be applied to deque's ect. It be nice if rootcint would generate code like this. I haven't checked what the StreamerInfo based I/O does, but also there this might help. Cheers, Walter -- Walter F.J. Mueller Mail: W.F.J.Mueller@gsi.de GSI, Abteilung KP3 Phone: +49-6159-71-2766 D-64291 Darmstadt FAX: +49-6159-71-2989 WWW: http://www-kp3.gsi.de/www/kp3/people/mueller.html PGP: http://www-kp3.gsi.de/~mueller/pgp.shtml
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:10 MET