STL Alternative

前端 未结 15 1818
故里飘歌
故里飘歌 2021-01-31 04:24

I really hate using STL containers because they make the debug version of my code run really slowly. What do other people use instead of STL that has reasonable performance for

相关标签:
15条回答
  • 2021-01-31 04:45

    If your running visual studios you may want to consider the following:

    #define _SECURE_SCL 0
    #define _HAS_ITERATOR_DEBUGGING 0
    

    That's just for iterators, what type of STL operations are you preforming? You may want to look at optimizing your memory operations; ie, using resize() to insert several elements at once instead of using pop/push to insert elements one at a time.

    0 讨论(0)
  • 2021-01-31 04:48

    Check out EASTL.

    0 讨论(0)
  • 2021-01-31 04:50

    Ultimate++ has its own set of containers - not sure if you can use them separatelly from the rest of the library: http://www.ultimatepp.org/

    0 讨论(0)
  • 2021-01-31 04:51

    Checkout Data Structures and Algorithms with Object-Oriented Design Patterns in C++ By Bruno Preiss http://www.brpreiss.com/

    0 讨论(0)
  • 2021-01-31 04:53

    I'll bet your STL uses a checked implementation for debug. This is probably a good thing, as it will catch iterator overruns and such. If it's that much of a problem for you, there may be a compiler switch to turn it off. Check your docs.

    0 讨论(0)
  • 2021-01-31 04:55

    My experience is that well designed STL code runs slowly in debug builds because the optimizer is turned off. STL containers emit a lot of calls to constructors and operator= which (if they are light weight) gets inlined/removed in release builds.

    Also, Visual C++ 2005 and up has checking enabled for STL in both release and debug builds. It is a huge performance hog for STL-heavy software. It can be disabled by defining _SECURE_SCL=0 for all your compilation units. Please note that having different _SECURE_SCL status in different compilation units will almost certainly lead to disaster.

    You could create a third build configuration with checking turned off and use that to debug with performance. I recommend you to keep a debug configuration with checking on though, since it's very helpful to catch erroneous array indices and stuff like that.

    0 讨论(0)
提交回复
热议问题