From a55333003d33ceb5857c315093bdd7e58af4ee92 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 31 Oct 2016 02:46:25 +0000 Subject: [PATCH] Optimize filesystem::path by providing weaker exception guarantees. path uses string::append to construct, append, and concatenate paths. Unfortunatly string::append has a strong exception safety guaranteed and if it can't prove that the iterator operations don't throw then it will allocate a temporary string copy to append to. However this extra allocation and copy is very undesirable for path which doesn't have the same exception guarantees. To work around this this patch adds string::__append_forward_unsafe which exposes the std::string::append interface for forward iterators without enforcing that the iterator is noexcept. llvm-svn: 285532 --- libcxx/benchmarks/CMakeLists.txt | 1 + libcxx/benchmarks/filesystem.bench.cpp | 34 +++++++++++++++++++++ libcxx/include/experimental/filesystem | 14 +++++++-- libcxx/include/string | 42 +++++++++++--------------- 4 files changed, 65 insertions(+), 26 deletions(-) diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt index 253fbd684711..a4105be08340 100644 --- a/libcxx/benchmarks/CMakeLists.txt +++ b/libcxx/benchmarks/CMakeLists.txt @@ -69,6 +69,7 @@ set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native) set(BENCHMARK_TEST_COMPILE_FLAGS -std=c++14 -O2 -I${BENCHMARK_LIBCXX_INSTALL}/include + -I${LIBCXX_SOURCE_DIR}/test/support ) set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS -nostdinc++ diff --git a/libcxx/benchmarks/filesystem.bench.cpp b/libcxx/benchmarks/filesystem.bench.cpp index 2cea3f69c673..f7949a163a7f 100644 --- a/libcxx/benchmarks/filesystem.bench.cpp +++ b/libcxx/benchmarks/filesystem.bench.cpp @@ -2,6 +2,7 @@ #include "benchmark/benchmark_api.h" #include "GenerateInput.hpp" +#include "test_iterators.h" namespace fs = std::experimental::filesystem; @@ -41,6 +42,39 @@ void BM_PathConstructCStr(benchmark::State &st, GenInputs gen) { BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string, getRandomStringInputs)->Arg(TestNumInputs); + +template