String class allocating on stack for small strings?

后端 未结 4 1834
臣服心动
臣服心动 2021-01-17 20:25

Do anyone know if there is a STL interface compatible string class that allocates memory for small strings on the stack (up to a certain threshold) and the heap for larger s

4条回答
  •  死守一世寂寞
    2021-01-17 20:39

    This is antique question, but I feel that this is better that any of the current answers.

    http://llvm.org/docs/ProgrammersManual.html#dss_smallstring

    Basically it is what you want. BTW tcmalloc increased perf in my (badly designed :D) string alloc intensive program 10%. Also you should profile to prove allocs are your perf problem.

提交回复
热议问题