Improve performance of constructing filesystem::path from strings.
authorEric Fiselier <eric@efcs.ca>
Sun, 30 Oct 2016 23:53:50 +0000 (23:53 +0000)
committerEric Fiselier <eric@efcs.ca>
Sun, 30 Oct 2016 23:53:50 +0000 (23:53 +0000)
commitef915d3ef476f9de691300b6c6f9862b6b5607f8
tree75869e0b7beb16030ce650e9538146d425e4d242
parent299e67291c49cf28cf42e77b2ecdce1485a60ceb
Improve performance of constructing filesystem::path from strings.

This patch fixes a performance bug when constructing or appending to a path
from a string or c-string. Previously we called 'push_back' to append every
single character. This caused multiple re-allocation and copies when at most
one reallocation is necessary. The new behavior is to simply call
`string::append` so it can correctly handle reallocation.

For large strings this change is a ~4x improvement. This also makes our path
faster to construct than libstdc++'s.

llvm-svn: 285530
libcxx/benchmarks/filesystem.bench.cpp
libcxx/include/experimental/filesystem
libcxx/src/experimental/filesystem/path.cpp