diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-02-07 14:34:41 +0600 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-02-07 11:23:58 +0100 |
commit | 093d174f959f8f9524d288c2a593f3a764a8a73c (patch) | |
tree | 4ec24b5e231cd6f42cb9e2774ed9db8a96596e89 /starmath/source/mathml | |
parent | e9531b792ddf0cfc2db11713b574c5fc7ae09e2c (diff) |
Simplify a bit, and avoid vector copy
Change-Id: I551a29f8451831e2908de8f4abba0f28bad9ef23
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163073
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'starmath/source/mathml')
-rw-r--r-- | starmath/source/mathml/element.cxx | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/starmath/source/mathml/element.cxx b/starmath/source/mathml/element.cxx index 424d94ccaddf..69b993beece5 100644 --- a/starmath/source/mathml/element.cxx +++ b/starmath/source/mathml/element.cxx @@ -110,6 +110,19 @@ constexpr SmMlAttributePos MlAttributeListMstyle[] = { { SmMlAttributeValueType::MlSymmetric, 17 } // clang-format on }; + +/// Generates an attribute vector of default values from an attribute position list. +/// @param aAttributePosList +/// @return attribute vector +std::vector<SmMlAttribute> makeMlAttributeList(std::span<SmMlAttributePos> aAttributePosList) +{ + std::vector<SmMlAttribute> aAttributeList(aAttributePosList.size()); + for (size_t i = 0; i < aAttributePosList.size(); ++i) + { + aAttributeList[i].setMlAttributeValueType(aAttributePosList[i].m_aAttributeValueType); + } + return aAttributeList; +} } void SmMlElement::SmImplAttributeType() @@ -161,7 +174,7 @@ void SmMlElement::SmImplAttributeType() break; } // Create attribute vector with given pattern - m_aAttributeList = starmathdatabase::makeMlAttributeList(m_aAttributePosList); + m_aAttributeList = makeMlAttributeList(m_aAttributePosList); } SmMlAttribute SmMlElement::getAttribute(SmMlAttributeValueType aAttributeType) const @@ -218,15 +231,4 @@ void SmMlElement::setSubElement(size_t nPos, SmMlElement* aElement) m_aSubElements[nPos] = aElement; } -std::vector<SmMlAttribute> -starmathdatabase::makeMlAttributeList(std::vector<SmMlAttributePos> aAttributePosList) -{ - std::vector<SmMlAttribute> aAttributeList(aAttributePosList.size()); - for (size_t i = 0; i < aAttributePosList.size(); ++i) - { - aAttributeList[i].setMlAttributeValueType(aAttributePosList[i].m_aAttributeValueType); - } - return aAttributeList; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |