Codechange: Shrink GUIList vectors less often, reserve before use.
After sorting and filter lists for GUI, we often shirnk them to reduce size. However this has very little benefit: 1) The memory has already been allocated, so it doesn't prevent that memory being required. 2) It causes a new allocation and copy when the vector is shrunk, actually using more memory. 3) The list is in window state, so the lifetime is only while the window is open. 4) When a filter is clearer, the original size will be needed again, which will cause another allocation. In fact it is beneficial to reserve to the known maximum in most cases, so do that instead.master
parent
8308998388
commit
33aedc43a5
Loading…
Reference in New Issue