refactor: prefer std::ranges over begin() and end() (#43464)

This commit is contained in:
Charles Kerr 2024-08-26 09:58:32 -05:00 committed by GitHub
parent 56829f75c1
commit 2390706030
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 30 additions and 40 deletions

View file

@ -409,15 +409,15 @@ void ClientFrameViewLinux::LayoutButtonsOnSide(
frame_buttons = trailing_frame_buttons_;
// We always lay buttons out going from the edge towards the center, but
// they are given to us as left-to-right, so reverse them.
std::reverse(frame_buttons.begin(), frame_buttons.end());
std::ranges::reverse(frame_buttons);
break;
default:
NOTREACHED();
}
for (views::FrameButton frame_button : frame_buttons) {
auto* button = std::find_if(
nav_buttons_.begin(), nav_buttons_.end(), [&](const NavButton& test) {
auto* button =
std::ranges::find_if(nav_buttons_, [&](const NavButton& test) {
return test.type != skip_type && test.frame_button == frame_button;
});
CHECK(button != nav_buttons_.end())

View file

@ -211,8 +211,7 @@ NotifyIcon* NotifyIconHost::CreateNotifyIcon(std::optional<UUID> guid) {
}
void NotifyIconHost::Remove(NotifyIcon* icon) {
NotifyIcons::iterator i(
std::find(notify_icons_.begin(), notify_icons_.end(), icon));
const auto i = std::ranges::find(notify_icons_, icon);
if (i == notify_icons_.end()) {
NOTREACHED();
@ -241,11 +240,7 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
LPARAM lparam) {
if (message == taskbar_created_message_) {
// We need to reset all of our icons because the taskbar went away.
for (NotifyIcons::const_iterator i(notify_icons_.begin());
i != notify_icons_.end(); ++i) {
auto* win_icon = static_cast<NotifyIcon*>(*i);
win_icon->ResetIcon();
}
std::ranges::for_each(notify_icons_, [](auto* icon) { icon->ResetIcon(); });
return TRUE;
} else if (message == kNotifyIconMessage) {
NotifyIcon* win_icon = nullptr;