[libc-commits] [libc] c3d78a7 - [libc][benchmarks] Tidy uses of raw_string_ostream (NFC)
Youngsuk Kim via libc-commits
libc-commits at lists.llvm.org
Tue Sep 17 08:27:20 PDT 2024
Author: Youngsuk Kim
Date: 2024-09-17T10:25:18-05:00
New Revision: c3d78a7af8e74c588501a2555b4a4ed7bdc55ef5
URL: https://github.com/llvm/llvm-project/commit/c3d78a7af8e74c588501a2555b4a4ed7bdc55ef5
DIFF: https://github.com/llvm/llvm-project/commit/c3d78a7af8e74c588501a2555b4a4ed7bdc55ef5.diff
LOG: [libc][benchmarks] Tidy uses of raw_string_ostream (NFC)
As specified in the docs,
1) raw_string_ostream is always unbuffered and
2) the underlying buffer may be used directly
( 65b13610a5226b84889b923bae884ba395ad084d for further reference )
Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
Added:
Modified:
libc/benchmarks/MemorySizeDistributions.cpp
libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp
Removed:
################################################################################
diff --git a/libc/benchmarks/MemorySizeDistributions.cpp b/libc/benchmarks/MemorySizeDistributions.cpp
index f003cebd9c3762..c3590297445dd1 100644
--- a/libc/benchmarks/MemorySizeDistributions.cpp
+++ b/libc/benchmarks/MemorySizeDistributions.cpp
@@ -197,7 +197,7 @@ getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions,
<< "', available distributions:\n";
for (const auto &MSD : Distributions)
Stream << "'" << MSD.Name << "'\n";
- report_fatal_error(Stream.str());
+ report_fatal_error(Message);
}
} // namespace libc_benchmarks
diff --git a/libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp b/libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp
index 17bc189fa3f127..a7fc8570a73b01 100644
--- a/libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp
+++ b/libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp
@@ -50,7 +50,7 @@ TEST(Automemcpy, Codegen) {
raw_string_ostream OutputStream(Output);
Serialize(OutputStream, kDescriptors);
- EXPECT_STREQ(OutputStream.str().c_str(),
+ EXPECT_STREQ(Output.c_str(),
R"(// This file is auto-generated by libc/benchmarks/automemcpy.
// Functions : 6
More information about the libc-commits
mailing list