diff options
author | Jacques Lucke <jacques@blender.org> | 2021-12-05 17:10:11 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-12-05 17:10:11 +0300 |
commit | b32f9bf801ec6cc0e3b40b87de16f34eba3f593e (patch) | |
tree | 6a1fb164156a65945aee22d6885747300dfaf0ae /source/blender/blenkernel/BKE_geometry_set.hh | |
parent | d19443074a8ed9a5717b56f0254bd416c5e76923 (diff) |
Geometry Nodes: use array instead of map in GeometrySet
`GeometrySet` contains at most one component of each type.
Previously, a map was used to make sure that each component
type only exists once. The overhead of a map (especially with
inline storage) is rather large though. Since all component types
are known at compile time and the number of types is low,
a simple `std::array` works as well.
Some benefits of using `std::array` here:
* Looking up the component of a specific type is a bit faster.
* The size of `GeometrySet` becomes much smaller from 192 to 40 bytes.
* Debugging a `GeometrySet` in many tools becomes simpler because
one can easily see which components exists and which don't
Diffstat (limited to 'source/blender/blenkernel/BKE_geometry_set.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_geometry_set.hh | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index ead62827104..84564ca5114 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -262,7 +262,8 @@ inline constexpr bool is_geometry_component_v = std::is_base_of_v<GeometryCompon struct GeometrySet { private: using GeometryComponentPtr = blender::UserCounter<class GeometryComponent>; - blender::Map<GeometryComponentType, GeometryComponentPtr> components_; + /* Indexed by #GeometryComponentType. */ + std::array<GeometryComponentPtr, GEO_COMPONENT_TYPE_ENUM_SIZE> components_; public: GeometrySet(); |