[gcc r14-6959] libstdc++: Remove unneeded double operation in src/c++17/fs_path.cc
Jonathan Wakely
redi@gcc.gnu.org
Fri Jan 5 14:42:04 GMT 2024
https://gcc.gnu.org/g:a3fee5ef891cc8e4f39fe118ab5a3e875fcc7088
commit r14-6959-ga3fee5ef891cc8e4f39fe118ab5a3e875fcc7088
Author: Martin Küttler <martin.kuettler@kernkonzept.com>
Date: Fri Jan 5 12:45:20 2024 +0000
libstdc++: Remove unneeded double operation in src/c++17/fs_path.cc
libstdc++-v3/ChangeLog:
* src/c++17/fs_path.cc (path::_List::reserve): Avoid
floating-point arithmetic.
Diff:
---
libstdc++-v3/src/c++17/fs_path.cc | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/src/c++17/fs_path.cc b/libstdc++-v3/src/c++17/fs_path.cc
index 4e41b891c2c..a2d3c54a88a 100644
--- a/libstdc++-v3/src/c++17/fs_path.cc
+++ b/libstdc++-v3/src/c++17/fs_path.cc
@@ -447,8 +447,9 @@ path::_List::reserve(int newcap, bool exact = false)
if (curcap < newcap)
{
- if (!exact && newcap < int(1.5 * curcap))
- newcap = 1.5 * curcap;
+ const int nextcap = curcap + curcap / 2;
+ if (!exact && newcap < nextcap)
+ newcap = nextcap;
void* p = ::operator new(sizeof(_Impl) + newcap * sizeof(value_type));
std::unique_ptr<_Impl, _Impl_deleter> newptr(::new(p) _Impl{newcap});
More information about the Libstdc++-cvs
mailing list