home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,906 of 33,346   
   Carlos Moreno to Mathias Gaunard   
   Re: Politics of using the standard libra   
   12 Feb 12 11:26:29   
   
   481aa9d5   
   From: moreno_news@mailinator.com   
      
   On 12-02-11 07:37 PM, Mathias Gaunard wrote:   
      
   >> I've failed to   
   >> demonstrate that std::vector is faster than our internal one.   
   >> Unfortunately my profiling uniformly suggests std::vector is 10% slower,   
   >   
   > That must mean that your custom vector class is not doing the same   
   > thing as std::vector, simply.   
   > For example std::vector initializes everything you put inside, which   
   > might not be your case. If your own vector doesn't initialize things,   
   > it also means it's unusable with types that are not PODs.   
      
   Hopefully you meant the opposite --- it's unusable with PODs   
   (and not even the case).   
      
   std::vector initializes built-in types;  a typical custom-made   
   array class just does new T[size], which does not initialize   
   built-ins;  but user-defined types are initialized in an   
   automatic way through a default constructor --- if no default   
   constructor is provided, new T[size] would fail to compile.   
      
   The only way is if they allocate raw memory, which I would be   
   very surprised if it was the case --- in which case, well,   
   if it doesn't initialize things somehow, then I'd say it's   
   unusable (unqualified!)   
      
      
   Another reason that could explain the 10% speed advantage   
   over std::vector is that it may have certain "hardcoded"   
   actions or structure that optimize things at the expense   
   of general-purposeness --- std::vector has to do things in   
   a general enough way to be useful in a variety of contexts;   
   a custom-made array class could drop certain features that   
   are not needed in the context where it's being used.  It   
   could place extra requirements on the types being used   
   that they know is a requirement that everything that they   
   use meets ...  etc.   
      
   Carlos   
   --   
      
      
      
   --   
         [ 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)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca