From 126aa9db88ae58978967c875cb1695189dfbbd2e Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 14 Feb 2019 12:27:11 -0800 Subject: [PATCH] mds: return string_view for type To avoid unnecessary heap allocation. Signed-off-by: Patrick Donnelly --- src/mds/LogEvent.cc | 2 +- src/mds/LogEvent.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mds/LogEvent.cc b/src/mds/LogEvent.cc index bafe4b4fbd5ea..3e321531a0c9e 100644 --- a/src/mds/LogEvent.cc +++ b/src/mds/LogEvent.cc @@ -67,7 +67,7 @@ std::unique_ptr LogEvent::decode_event(bufferlist::const_iterator p) } -std::string LogEvent::get_type_str() const +std::string_view LogEvent::get_type_str() const { switch(_type) { case EVENT_SUBTREEMAP: return "SUBTREEMAP"; diff --git a/src/mds/LogEvent.h b/src/mds/LogEvent.h index 73e2438f6273f..7c7273f8f986d 100644 --- a/src/mds/LogEvent.h +++ b/src/mds/LogEvent.h @@ -62,7 +62,7 @@ public: LogEvent& operator=(const LogEvent&) = delete; virtual ~LogEvent() {} - string get_type_str() const; + std::string_view get_type_str() const; static EventType str_to_type(std::string_view str); EventType get_type() const { return _type; } void set_type(EventType t) { _type = t; } -- 2.39.5