From: buckelew@knology.net   
      
   On 2/11/2012 6:33 PM, Zeljko Vrba wrote:   
   > On 2012-02-10, Richard Smith wrote:   
   >>   
   >> I'm doing some coding in my spare time on an open source C++ project   
   >> which I won't name the project to avoid any embarrassment. The code   
   >>   
   > Actually, a better advice, IMO. Given this, I assume that you're not   
   > being payed, i.e., you don't rely on income from this project. If true,   
   > this means you have a MUCH greater freedom in what you can do than you   
   > would have had otherwise.   
   >   
   > So: don't do anything, just start using the standard library on your own.   
   > When you discover a bug (e.g., memory leak), fix it by using scoped_ptr   
   > instead of adding delete. Etc. You might eventually be kicked out of   
   > the project, but would it really be a big deal?   
   >   
   > PS: STL is unpredictable; I got burned on it myself. IIRC, I had a   
   > vector of structures like this one:   
   >   
   > struct pair {   
   > int a, b, c;   
   > pair(int _a, int _b) : a(_a), b(_b)   
   > { }   
   > }   
   >   
   > I frequently called vector.clear, which turned out to be a severe   
   > performance bottleneck: you would expect clear to be O(1) since the   
   > destructor is empty, but it obviously wasn't: reducing the vector size   
   > from 1024 to 17 made an orders of magnitude improvement in running   
   > time (the vector was used as a storage for open-addressing hashing   
   > scheme). Also, some memory reallocations were going on there.   
      
      
   It is surprising that the compiler could not optimize this away. Note   
   that if you frequently used vector.clear that on some implementations   
   that would cause a deallocation and the capacity of the vector to be   
   zero. Requiring a allocation on next use. That could be slow. (i   
   usually use vector.resize(0) is those cases to be sure).   
      
   Note that the collection that you are using has "dark corners" as well.   
      
      
   { trailing quotation removed -mod }   
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|