diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-05-27 10:43:16 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2021-05-31 10:22:24 +0200 |
commit | 1bafb0dd8bd1a210e23c02491e81a29a0722e3da (patch) | |
tree | 43be7d36238b513f428bd21df3ec474fb949a731 | |
parent | 2ff02e6d31702611d0294c31b69f043b61d22a47 (diff) |
Avoid empty std::map constructor
Change-Id: Ie1bc333409fb201d82dd2cff7597e281600f01db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116232
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r-- | include/comphelper/profilezone.hxx | 24 | ||||
-rw-r--r-- | include/comphelper/traceevent.hxx | 20 |
2 files changed, 32 insertions, 12 deletions
diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx index ebaae5aa43e8..36730e7f8af6 100644 --- a/include/comphelper/profilezone.hxx +++ b/include/comphelper/profilezone.hxx @@ -30,13 +30,8 @@ class COMPHELPER_DLLPUBLIC ProfileZone : public NamedEvent void addRecording(); - public: - - // Note that the char pointer is stored as such in the ProfileZone object and used in the - // destructor, so be sure to pass a pointer that stays valid for the duration of the object's - // lifetime. - ProfileZone(const char* sName, const std::map<OUString, OUString> &args = std::map<OUString, OUString>()) - : NamedEvent(sName, args) + ProfileZone(const char* sName, const OUString &sArgs) + : NamedEvent(sName, sArgs) , m_nNesting(-1) { if (s_bRecording) @@ -51,6 +46,21 @@ class COMPHELPER_DLLPUBLIC ProfileZone : public NamedEvent m_nCreateTime = 0; } + public: + + // Note that the char pointer is stored as such in the ProfileZone object and used in the + // destructor, so be sure to pass a pointer that stays valid for the duration of the object's + // lifetime. + ProfileZone(const char* sName, const std::map<OUString, OUString> &aArgs) + : ProfileZone(sName, createArgsString(aArgs)) + { + } + + ProfileZone(const char* sName) + : ProfileZone(sName, OUString()) + { + } + ~ProfileZone() { if (m_nCreateTime > 0) diff --git a/include/comphelper/traceevent.hxx b/include/comphelper/traceevent.hxx index 339e924e637d..cc3c390d7e59 100644 --- a/include/comphelper/traceevent.hxx +++ b/include/comphelper/traceevent.hxx @@ -82,9 +82,14 @@ protected: const int m_nPid; const OUString m_sArgs; - TraceEvent(std::map<OUString, OUString> args) + TraceEvent(const OUString& sArgs) : m_nPid(getPid()) - , m_sArgs(createArgsString(args)) + , m_sArgs(sArgs) + { + } + + TraceEvent(std::map<OUString, OUString> args) + : TraceEvent(createArgsString(args)) { } @@ -105,9 +110,14 @@ class COMPHELPER_DLLPUBLIC NamedEvent : public TraceEvent protected: const char* m_sName; - NamedEvent(const char* sName, - const std::map<OUString, OUString>& args = std::map<OUString, OUString>()) - : TraceEvent(args) + NamedEvent(const char* sName, const OUString& sArgs) + : TraceEvent(sArgs) + , m_sName(sName ? sName : "(null)") + { + } + + NamedEvent(const char* sName, const std::map<OUString, OUString>& aArgs) + : TraceEvent(aArgs) , m_sName(sName ? sName : "(null)") { } |