dancol added inline comments.

================
Comment at: source/Core/Log.cpp:78
+  char *text;
+  vasprintf(&text, format, args);
+  message << text;
----------------
I usually implement printf-into-std::string by using `vsnprintf` to figure out 
how many characters we generate, using `std::string::resize` to create a buffer 
of that many characters (unfortunately, zero-filling them), then `vsnprintf` 
directly into that buffer. This way, you only need one allocation.

The currant approach involves at least three allocations: first, the string 
generated by `vasprintf`. Second, the internal `stringstream` buffer. Third, 
the copy of the buffer that `std::stringstream::str` generates.

It's more expensive that it needs to be.


https://reviews.llvm.org/D27459



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to