[LLVMdev] std::string

Sean Silva silvas at purdue.edu
Sat Jan 19 17:55:13 PST 2013

On Sat, Jan 19, 2013 at 8:33 PM, Michael Spencer <bigcheesegs at gmail.com> wrote:
> There isn't much use of std::string in LLVM because it's simply not
> needed. There's very little string manipulation, so StringRef is often
> a much better choice. When there is a need for string manipulation,
> the strings are generally very short, so SmallString is better.

Although SmallString is actually pretty inefficient, since it keeps
the string data separate from the "vector" header. I believe libc++'s
std::string actually reuses the pointers in the "vector header" as the
storage for the "small" size, and so in that case std::string is
effectively a very memory efficient SmallString with storage of
roughly 3 pointers' worth of chars.

-- Sean Silva

More information about the llvm-dev mailing list