[PATCH] D58580: [Support] llvm::to_string(): raw_string_ostream is a memory hog
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 25 11:08:52 PST 2019
rnk added a comment.
In D58580#1409470 <https://reviews.llvm.org/D58580#1409470>, @lebedev.ri wrote:
> In D58580#1409395 <https://reviews.llvm.org/D58580#1409395>, @rnk wrote:
>
> > `operator<<` does this internally, see `write_unsigned_impl`. Instead of doing this, let's just disable buffering in raw_string_ostream. We already do it in raw_svector_ostream.
>
>
> I can do that, but i don't think i will be able to do any benchmarks. Will that change be ok as-is?
I don't think it needs to be benchmarked. Looking at the callers, for most of them it will save one 8K alloc/free. I'm assuming that repeated `std::string::append` isn't O(n^2) in any STL we care about. At the end of the day, anything we put into a std::string is small enough to put in memory, and shouldn't be performance sensitive.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58580/new/
https://reviews.llvm.org/D58580
More information about the llvm-commits
mailing list