Skip to content

Commit

Permalink
libstdc++: Remove unneeded double operation in src/c++17/fs_path.cc
Browse files Browse the repository at this point in the history
libstdc++-v3/ChangeLog:

	* src/c++17/fs_path.cc (path::_List::reserve): Avoid
	floating-point arithmetic.
  • Loading branch information
mkuettle authored and jwakely committed Jan 5, 2024
1 parent 57fa5b6 commit a3fee5e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libstdc++-v3/src/c++17/fs_path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down

0 comments on commit a3fee5e

Please sign in to comment.