Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Yurkovich <deadpin>2022-03-24 23:13:02 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-03-24 23:26:11 +0300
commit07846b31f34caa88244d192ee7d3aa6c057ac602 (patch)
tree974a462edcc14d115010cfe6f75d903f191bba65 /source/blender/draw/intern
parent3c4947cdaa04ac0afa69157a1788b9022b20905e (diff)
Cleanup: Optimize viewport view data creation
Each time the user clicks the viewport 2 sets of engine views are created. Each set is currently composed of 8 view objects, each of size 592 bytes. Because space is not reserved in the vector that holds them, several unnecessary re-allocation/copy cycles occur as the vector resizes and the total allocation load is 8880 bytes. This happens twice. Reduce to just the allocations necessary and with exactly 4736 bytes allocated for each set - Before: 8 allocations and 8 deallocations totaling 17760 bytes - After: 2 allocations and 2 deallocations totaling 9472 bytes Reviewed By: fclem, jbakker Differential Revision: https://developer.blender.org/D13782
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r--source/blender/draw/intern/draw_view_data.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_view_data.cc b/source/blender/draw/intern/draw_view_data.cc
index 682728eb22b..0e55d28f6df 100644
--- a/source/blender/draw/intern/draw_view_data.cc
+++ b/source/blender/draw/intern/draw_view_data.cc
@@ -37,7 +37,10 @@ struct DRWViewData {
DRWViewData *DRW_view_data_create(ListBase *engine_types)
{
+ const int engine_types_len = BLI_listbase_count(engine_types);
+
DRWViewData *view_data = new DRWViewData();
+ view_data->engines.reserve(engine_types_len);
LISTBASE_FOREACH (DRWRegisteredDrawEngine *, type, engine_types) {
ViewportEngineData engine = {};
engine.engine_type = type;