[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Sep 18 07:07:01 UTC 2018
sw/source/uibase/inc/initui.hxx | 10 +++++-----
sw/source/uibase/utlui/initui.cxx | 31 ++++++++++++-------------------
2 files changed, 17 insertions(+), 24 deletions(-)
New commits:
commit e662968999a904244c2be826128660a66f1d78e3
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Sep 14 14:51:20 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Sep 18 09:06:37 2018 +0200
loplugin:useuniqueptr in initui
Change-Id: I19f4762b17fcd6841b7c6520770400297f59dd03
Reviewed-on: https://gerrit.libreoffice.org/60608
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/uibase/inc/initui.hxx b/sw/source/uibase/inc/initui.hxx
index 2278dd9138ec..246f7d274a29 100644
--- a/sw/source/uibase/inc/initui.hxx
+++ b/sw/source/uibase/inc/initui.hxx
@@ -35,16 +35,16 @@ class SwThesaurus;
*/
extern SwThesaurus* pThes;
-SW_DLLPUBLIC OUString GetOldGrfCat();
+SW_DLLPUBLIC const OUString& GetOldGrfCat();
SW_DLLPUBLIC void SetOldGrfCat(const OUString& sStr);
-SW_DLLPUBLIC OUString GetOldTabCat();
+SW_DLLPUBLIC const OUString& GetOldTabCat();
SW_DLLPUBLIC void SetOldTabCat(const OUString& sStr);
-SW_DLLPUBLIC OUString GetOldFrameCat();
+SW_DLLPUBLIC const OUString& GetOldFrameCat();
SW_DLLPUBLIC void SetOldFrameCat(const OUString& sStr);
-SW_DLLPUBLIC OUString GetOldDrwCat();
+SW_DLLPUBLIC const OUString& GetOldDrwCat();
SW_DLLPUBLIC void SetOldDrwCat(const OUString& sStr);
-SW_DLLPUBLIC OUString GetCurrGlosGroup();
+SW_DLLPUBLIC const OUString& GetCurrGlosGroup();
SW_DLLPUBLIC void SetCurrGlosGroup(const OUString& sStr);
// provides textblock management
diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx
index 356e08be6feb..2b8d43bd7a5b 100644
--- a/sw/source/uibase/utlui/initui.cxx
+++ b/sw/source/uibase/utlui/initui.cxx
@@ -56,36 +56,29 @@ enum CachedStringID
CachedStrings
};
-OUString *StringCache[CachedStrings] = {nullptr};
+OUString StringCache[CachedStrings];
-inline OUString GetCachedString(CachedStringID id)
+const OUString& GetCachedString(CachedStringID id)
{
- return StringCache[id] ? *StringCache[id] : OUString();
+ return StringCache[id];
}
-inline void SetCachedString(CachedStringID id, const OUString& sStr)
+void SetCachedString(CachedStringID id, const OUString& sStr)
{
- if (StringCache[id])
- {
- *StringCache[id] = sStr;
- }
- else
- {
- StringCache[id] = new OUString(sStr);
- }
+ StringCache[id] = sStr;
}
void ClearStringCache()
{
- for (OUString* p : StringCache)
+ for (auto & s : StringCache)
{
- delete p;
+ s.clear();
}
}
}
-OUString GetOldGrfCat()
+const OUString& GetOldGrfCat()
{
return GetCachedString(OldGrfCat);
}
@@ -95,7 +88,7 @@ void SetOldGrfCat(const OUString& sStr)
SetCachedString(OldGrfCat, sStr);
}
-OUString GetOldTabCat()
+const OUString& GetOldTabCat()
{
return GetCachedString(OldTabCat);
}
@@ -105,7 +98,7 @@ void SetOldTabCat(const OUString& sStr)
SetCachedString(OldTabCat, sStr);
}
-OUString GetOldFrameCat()
+const OUString& GetOldFrameCat()
{
return GetCachedString(OldFrameCat);
}
@@ -115,7 +108,7 @@ void SetOldFrameCat(const OUString& sStr)
SetCachedString(OldFrameCat, sStr);
}
-OUString GetOldDrwCat()
+const OUString& GetOldDrwCat()
{
return GetCachedString(OldDrwCat);
}
@@ -125,7 +118,7 @@ void SetOldDrwCat(const OUString& sStr)
SetCachedString(OldDrwCat, sStr);
}
-OUString GetCurrGlosGroup()
+const OUString& GetCurrGlosGroup()
{
return GetCachedString(CurrGlosGroup);
}
More information about the Libreoffice-commits
mailing list