aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/desktop
diff options
context:
space:
mode:
authorTom Englund <[email protected]>2024-10-28 19:02:52 +0100
committerGitHub <[email protected]>2024-10-28 18:02:52 +0000
commitc7315617eb6186912d03232e1968f32b88f153f2 (patch)
tree7e22a153c332378439c72ebf4bb06f6069411527 /src/desktop
parentd49a1334a8af7c704626cdf1746cb72415ad6d0d (diff)
downloadHyprland-c7315617eb6186912d03232e1968f32b88f153f2.tar.gz
Hyprland-c7315617eb6186912d03232e1968f32b88f153f2.zip
internal: few more marginal optimisations from profiling (#8271)
* deco: reduce local temporars and function calls profiling shows this is a high used function, reduce the amount of function calls and local temporar copies and also check if we even need to add extents at all in the loop. * popup: optimize bfhelper in popups pass nodes as const reference and reserve the size of the children node vector help reduce the reallocations. * procotol: make compositor bfhelper use const ref use const ref for nodes and reserve second nodes vector size to reduce amount of reallocation needed.
Diffstat (limited to 'src/desktop')
-rw-r--r--src/desktop/Popup.cpp3
-rw-r--r--src/desktop/Popup.hpp2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp
index 9e254fa6..58995f00 100644
--- a/src/desktop/Popup.cpp
+++ b/src/desktop/Popup.cpp
@@ -288,12 +288,13 @@ bool CPopup::visible() {
return false;
}
-void CPopup::bfHelper(std::vector<CPopup*> nodes, std::function<void(CPopup*, void*)> fn, void* data) {
+void CPopup::bfHelper(std::vector<CPopup*> const& nodes, std::function<void(CPopup*, void*)> fn, void* data) {
for (auto const& n : nodes) {
fn(n, data);
}
std::vector<CPopup*> nodes2;
+ nodes2.reserve(nodes.size() * 2);
for (auto const& n : nodes) {
for (auto const& c : n->m_vChildren) {
diff --git a/src/desktop/Popup.hpp b/src/desktop/Popup.hpp
index 04996612..f34b8a2c 100644
--- a/src/desktop/Popup.hpp
+++ b/src/desktop/Popup.hpp
@@ -81,5 +81,5 @@ class CPopup {
Vector2D localToGlobal(const Vector2D& rel);
Vector2D t1ParentCoords();
- static void bfHelper(std::vector<CPopup*> nodes, std::function<void(CPopup*, void*)> fn, void* data);
+ static void bfHelper(std::vector<CPopup*> const& nodes, std::function<void(CPopup*, void*)> fn, void* data);
};