perf: avoid a triple-redundant map lookup in ViewsDelegate::GetAppbarAutohideEdges() (#46335)

perf: avoid a triple-redundant map lookup in ViewsDelegate::GetAppbarAutohideEdges()

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-03-27 19:21:42 -05:00 committed by GitHub
parent b4fc140f1a
commit cb7335b4f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -119,8 +119,8 @@ int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor,
// in us thinking there is no auto-hide edges. By returning at least one edge
// we don't initially go fullscreen until we figure out the real auto-hide
// edges.
if (!appbar_autohide_edge_map_.contains(monitor))
appbar_autohide_edge_map_[monitor] = EDGE_BOTTOM;
auto [iter, _] = appbar_autohide_edge_map_.try_emplace(monitor, EDGE_BOTTOM);
const int edges{iter->second};
// We use the SHAppBarMessage API to get the taskbar autohide state. This API
// spins a modal loop which could cause callers to be reentered. To avoid
@ -133,9 +133,9 @@ int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor,
base::BindOnce(&GetAppbarAutohideEdgesOnWorkerThread, monitor),
base::BindOnce(&ViewsDelegate::OnGotAppbarAutohideEdges,
weak_factory_.GetWeakPtr(), std::move(callback), monitor,
appbar_autohide_edge_map_[monitor]));
edges));
}
return appbar_autohide_edge_map_[monitor];
return edges;
}
void ViewsDelegate::OnGotAppbarAutohideEdges(base::OnceClosure callback,