include/svl/IndexedStyleSheets.hxx | 5 ++++- svl/source/items/IndexedStyleSheets.cxx | 7 +------ 2 files changed, 5 insertions(+), 7 deletions(-)
New commits: commit 1406e7b2f01a88377649c763cd65d20803c3c3a6 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Mar 8 08:22:09 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Mar 8 13:36:11 2024 +0100 tdf#158773 flatten data of IndexedStyleSheets we can store the mStyleSheetPositionsByFamily inline, since it is fixed size, and save some allocation overhead, and some pointer chasing. Change-Id: Id6ff02491e967b9fb145ba9752f4a52173692645 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164558 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svl/IndexedStyleSheets.hxx b/include/svl/IndexedStyleSheets.hxx index 910acd9e2566..f358f234b84e 100644 --- a/include/svl/IndexedStyleSheets.hxx +++ b/include/svl/IndexedStyleSheets.hxx @@ -17,6 +17,7 @@ #include <svl/svldllapi.h> #include <unordered_map> +#include <array> #include <vector> namespace svl @@ -172,7 +173,9 @@ private: /** A map which stores the positions of style sheets by their name */ MapType mPositionsByName; - std::vector<std::vector<sal_Int32>> mStyleSheetPositionsByFamily; + static constexpr size_t NUMBER_OF_FAMILIES = 7; + + std::array<std::vector<sal_Int32>, NUMBER_OF_FAMILIES> mStyleSheetPositionsByFamily; }; } /* namespace svl */ diff --git a/svl/source/items/IndexedStyleSheets.cxx b/svl/source/items/IndexedStyleSheets.cxx index c4b879d4f9c2..fd3962474db8 100644 --- a/svl/source/items/IndexedStyleSheets.cxx +++ b/svl/source/items/IndexedStyleSheets.cxx @@ -17,7 +17,6 @@ namespace { -const size_t NUMBER_OF_FAMILIES = 7; size_t family_to_index(SfxStyleFamily family) { switch (family) { @@ -46,10 +45,7 @@ namespace svl { IndexedStyleSheets::IndexedStyleSheets() { - for (size_t i = 0; i < NUMBER_OF_FAMILIES; i++) { - mStyleSheetPositionsByFamily.emplace_back(); - } -;} +} void IndexedStyleSheets::Register(const SfxStyleSheetBase& style, sal_Int32 pos) { @@ -64,7 +60,6 @@ void IndexedStyleSheets::Reindex() { mPositionsByName.clear(); - mStyleSheetPositionsByFamily.resize(NUMBER_OF_FAMILIES); for (size_t i = 0; i < NUMBER_OF_FAMILIES; i++) { mStyleSheetPositionsByFamily[i].clear(); }