summaryrefslogtreecommitdiffstats
path: root/libcxx/include/experimental/filesystem
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-10-31 02:46:25 +0000
committerEric Fiselier <eric@efcs.ca>2016-10-31 02:46:25 +0000
commita55333003d33ceb5857c315093bdd7e58af4ee92 (patch)
tree29dbcb56c961738426df3f367c0b1ba1dc74500a /libcxx/include/experimental/filesystem
parent7ca76565e7c3e206011072673347e7ab63428207 (diff)
downloadbcm5719-llvm-a55333003d33ceb5857c315093bdd7e58af4ee92.tar.gz
bcm5719-llvm-a55333003d33ceb5857c315093bdd7e58af4ee92.zip
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
Diffstat (limited to 'libcxx/include/experimental/filesystem')
-rw-r--r--libcxx/include/experimental/filesystem14
1 files changed, 12 insertions, 2 deletions
diff --git a/libcxx/include/experimental/filesystem b/libcxx/include/experimental/filesystem
index c674a03695f..410235f11a3 100644
--- a/libcxx/include/experimental/filesystem
+++ b/libcxx/include/experimental/filesystem
@@ -625,8 +625,18 @@ template <>
struct _PathCVT<char> {
template <class _Iter>
- static void __append_range(string& __dest, _Iter __b, _Iter __e) {
- __dest.append(__b, __e);
+ static typename enable_if<
+ __is_exactly_input_iterator<_Iter>::value
+ >::type __append_range(string& __dest, _Iter __b, _Iter __e) {
+ for (; __b != __e; ++__b)
+ __dest.push_back(*__b);
+ }
+
+ template <class _Iter>
+ static typename enable_if<
+ __is_forward_iterator<_Iter>::value
+ >::type __append_range(string& __dest, _Iter __b, _Iter __e) {
+ __dest.__append_forward_unsafe(__b, __e);
}
template <class _Iter>
OpenPOWER on IntegriCloud