svx/source/svdraw/svdobj.cxx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
New commits: commit 9cab0b1bc03e494b003c73601821d6d40a30ba86 Author: Noel Grandin <[email protected]> AuthorDate: Tue Feb 10 13:27:36 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Fri Feb 13 09:46:38 2026 +0100 tdf#170595 speed up SdrObject::MakeNameUnique a little we only need to check for strings with a similar baseline, which reduces time spent inserting into the hashset and probing the hashset Change-Id: I09e74fb4818f7decaf72c5cdc825de4b4b4fa0d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199264 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 000f0e77e97d..b8e0b1fb7212 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -3216,6 +3216,16 @@ void SdrObject::MakeNameUnique(std::unordered_set<OUString>& rNameSet) if (GetName().isEmpty()) return; + OUString sName(GetName().trim()); + OUString sRootName(sName); + + if (!sName.isEmpty() && rtl::isAsciiDigit(sName[sName.getLength() - 1])) + { + sal_Int32 nPos(sName.getLength() - 1); + while (nPos > 0 && rtl::isAsciiDigit(sName[--nPos])); + sRootName = o3tl::trim(sName.subView(0, nPos + 1)); + } + if (rNameSet.empty()) { SdrPage* pPage; @@ -3228,21 +3238,15 @@ void SdrObject::MakeNameUnique(std::unordered_set<OUString>& rNameSet) { pObj = aIter.Next(); if (pObj != this) - rNameSet.insert(pObj->GetName()); + { + auto rName = pObj->GetName(); + if (rName.startsWith(sRootName)) + rNameSet.insert(rName); + } } } } - OUString sName(GetName().trim()); - OUString sRootName(sName); - - if (!sName.isEmpty() && rtl::isAsciiDigit(sName[sName.getLength() - 1])) - { - sal_Int32 nPos(sName.getLength() - 1); - while (nPos > 0 && rtl::isAsciiDigit(sName[--nPos])); - sRootName = o3tl::trim(sName.subView(0, nPos + 1)); - } - for (sal_uInt32 n = 1; rNameSet.find(sName) != rNameSet.end(); n++) sName = sRootName + " " + OUString::number(n); rNameSet.insert(sName);
