public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-6959] libstdc++: Remove unneeded double operation in src/c++17/fs_path.cc
@ 2024-01-05 14:42 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2024-01-05 14:42 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
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});
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-05 14:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-05 14:42 [gcc r14-6959] libstdc++: Remove unneeded double operation in src/c++17/fs_path.cc Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).