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 | |
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>
-rw-r--r-- | starmath/inc/mathml/element.hxx | 10 | ||||
-rw-r--r-- | starmath/source/mathml/element.cxx | 26 |
2 files changed, 14 insertions, 22 deletions
diff --git a/starmath/inc/mathml/element.hxx b/starmath/inc/mathml/element.hxx index 3b39edbf126e..90dc65439e62 100644 --- a/starmath/inc/mathml/element.hxx +++ b/starmath/inc/mathml/element.hxx @@ -287,14 +287,4 @@ public: // text elements void setText(const OUString& rText) { m_aText = rText; }; }; -namespace starmathdatabase -{ -/** - * Generates an attribute vector of default values from an attribute position list. - * @param aAttributePosList - * @return attribute vector - */ -std::vector<SmMlAttribute> makeMlAttributeList(std::vector<SmMlAttributePos> aAttributePosList); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ 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: */ |