]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Remove unneeded double operation in src/c++17/fs_path.cc
authorMartin Küttler <martin.kuettler@kernkonzept.com>
Fri, 5 Jan 2024 12:45:20 +0000 (12:45 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 5 Jan 2024 13:57:05 +0000 (13:57 +0000)
libstdc++-v3/ChangeLog:

* src/c++17/fs_path.cc (path::_List::reserve): Avoid
floating-point arithmetic.

libstdc++-v3/src/c++17/fs_path.cc

index 4e41b891c2c6398f4266dc4d5946ac7653670228..a2d3c54a88a4364d7a81745726a8fb101ab44e09 100644 (file)
@@ -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});