aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/basic_string.tcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2016-09-23 18:25:23 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2016-09-23 18:25:23 +0100
commita922c5ff6f3872fc9ce1e484a0e92f288ff6c68d (patch)
tree62231e54ad2ab9735e402dda27e441a3c84f50bb /libstdc++-v3/include/bits/basic_string.tcc
parentb862552dff04fbd4c7debf07a7c82d361869a552 (diff)
Optimize truncating a basic_string
* include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI] (basic_string::erase(size_type, size_type)): Add fast path for truncating the string, by calling _M_set_length directly. (basic_string::erase(__const_iterator, __const_iterator)): Likewise. * include/bits/basic_string.tcc [_GLIBCXX_USE_CXX11_ABI] (basic_string::resize(size_type, _CharT)): Likewise. From-SVN: r240446
Diffstat (limited to 'libstdc++-v3/include/bits/basic_string.tcc')
-rw-r--r--libstdc++-v3/include/bits/basic_string.tcc2
1 files changed, 1 insertions, 1 deletions
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 0080d2b0e2f..df1e8ddec75 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -351,7 +351,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if (__size < __n)
this->append(__n - __size, __c);
else if (__n < __size)
- this->_M_erase(__n, __size - __n);
+ this->_M_set_length(__n);
}
template<typename _CharT, typename _Traits, typename _Alloc>