summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-13 12:12:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-14 17:31:16 +0200
commitd4f2b8eb74f430f5fc3622d668b33df1f99a0c1d (patch)
tree5467b6f7efd55a9ff767587046c2118b95bb598d /vcl/source
parent652ac2fb11adaea2ab6b07718aa86579de025a72 (diff)
use more string_view in getNameNoExtension
to avoid some allocation Change-Id: Ic8d42af03a4ffd15414e3458b5b08e04ded43114 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134313 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/image/ImplImageTree.cxx22
1 files changed, 11 insertions, 11 deletions
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx
index 5f2d1e94af6a..ae9baacd55ca 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -134,10 +134,10 @@ bool urlExists(OUString const & sUrl)
return osl::FileBase::E_None == eRC;
}
-OUString getNameNoExtension(std::u16string_view sName)
+std::u16string_view getNameNoExtension(std::u16string_view sName)
{
size_t nDotPosition = sName.rfind('.');
- return OUString(sName.substr(0, nDotPosition));
+ return sName.substr(0, nDotPosition);
}
std::shared_ptr<SvMemoryStream> wrapStream(uno::Reference<io::XInputStream> const & rInputStream)
@@ -222,15 +222,15 @@ std::vector<OUString> ImplImageTree::getPaths(OUString const & name, LanguageTag
{
for (const OUString& rFallback : rLanguageTag.getFallbackStrings(true))
{
- OUString aFallbackName = getNameNoExtension(getRealImageName(createPath(name, pos, rFallback)));
- sPaths.emplace_back(aFallbackName + ".png");
- sPaths.emplace_back(aFallbackName + ".svg");
+ std::u16string_view aFallbackName = getNameNoExtension(getRealImageName(createPath(name, pos, rFallback)));
+ sPaths.emplace_back(OUString::Concat(aFallbackName) + ".png");
+ sPaths.emplace_back(OUString::Concat(aFallbackName) + ".svg");
}
}
- OUString aRealName = getNameNoExtension(getRealImageName(name));
- sPaths.emplace_back(aRealName + ".png");
- sPaths.emplace_back(aRealName + ".svg");
+ std::u16string_view aRealName = getNameNoExtension(getRealImageName(name));
+ sPaths.emplace_back(OUString::Concat(aRealName) + ".png");
+ sPaths.emplace_back(OUString::Concat(aRealName) + ".svg");
return sPaths;
}
@@ -624,15 +624,15 @@ OUString const & ImplImageTree::getRealImageName(OUString const & rIconName)
{
IconLinkHash & rLinkHash = maIconSets[maCurrentStyle].maLinkHash;
- OUString sNameWithNoExtension = getNameNoExtension(rIconName);
+ std::u16string_view sNameWithNoExtension = getNameNoExtension(rIconName);
// PNG is priority
- auto it = rLinkHash.find(sNameWithNoExtension + ".png");
+ auto it = rLinkHash.find(OUString::Concat(sNameWithNoExtension) + ".png");
if (it != rLinkHash.end())
return it->second;
// also check SVG name
- it = rLinkHash.find(sNameWithNoExtension + ".svg");
+ it = rLinkHash.find(OUString::Concat(sNameWithNoExtension) + ".svg");
if (it != rLinkHash.end())
return it->second;