-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanups and enhancements for basic_string
#3984
Conversation
@@ -2731,7 +2730,7 @@ private: | |||
} | |||
|
|||
_Elem* const _Old_ptr = _My_data._Myptr(); | |||
size_type _New_capacity = _Calculate_growth(_My_data._Mysize); | |||
size_type _New_capacity = _Calculate_growth(_My_data._Mysize + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not practically behavior-changing (won't affect resulting value), but I think it will be clearer to +1
, as this is the only place that use _Mysize
as input, and _Calculate_growth
accept the first argument as _Requested
, and this will be in line with push_back
(using _Reallocate_grow_by(1, ...)
which does _Calculate_growth(_My_data._Mysize + 1,...)
.
I'm neutral about +1
change, as it might slightly affect codegen; a comment about why to use _My_data._Mysize
(just to do x1.5
evaluation) might be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think + 1
makes sense here.
|
@@ -4274,9 +4264,6 @@ public: | |||
auto& _My_data = _Mypair._Myval2; | |||
auto& _Right_data = _Right._Mypair._Myval2; | |||
|
|||
const bool _My_large = _My_data._Large_mode_engaged(); | |||
const bool _Right_large = _Right_data._Large_mode_engaged(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 4272 in 60f1885
using _STD swap; |
Is it encouraged to move this
using _STD swap
into the if block where it is used? I'm not sure as I find using _STD swap
is usually defined at the beginning of functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making it as local as possible seems like an improvement.
Not sure whether we should remove the strengthening, since
See #1035. I think we should say |
@@ -4274,9 +4264,6 @@ public: | |||
auto& _My_data = _Mypair._Myval2; | |||
auto& _Right_data = _Right._Mypair._Myval2; | |||
|
|||
const bool _My_large = _My_data._Large_mode_engaged(); | |||
const bool _Right_large = _Right_data._Large_mode_engaged(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making it as local as possible seems like an improvement.
@@ -2731,7 +2730,7 @@ private: | |||
} | |||
|
|||
_Elem* const _Old_ptr = _My_data._Myptr(); | |||
size_type _New_capacity = _Calculate_growth(_My_data._Mysize); | |||
size_type _New_capacity = _Calculate_growth(_My_data._Mysize + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think + 1
makes sense here.
All of these cleanups look great - thanks! |
I have enough confidence in these cleanups to merge them without a second maintainer approval. |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
🧵 🧶 🧹 |
_Memcpy_val_from
to its only caller.basic_string(initializer_list)
basic_string(&&, off)
. The rvalue will be unchanged if exception is thrown from_Alloc_proxy()
.noexcept
enhancements, mainly for comparisons with c-string.