From 2b014a0464544ff8fc57ef405dbb7d688587bc82 Mon Sep 17 00:00:00 2001 From: lihangyu <15605149486@163.com> Date: Sat, 4 Mar 2023 15:08:59 +0800 Subject: [PATCH] [Improve](doris::Status performance) fix the performance issue due to copy of std::string (#17411) --- be/src/common/status.h | 2 +- be/src/service/backend_options.cpp | 2 +- be/src/service/backend_options.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/be/src/common/status.h b/be/src/common/status.h index acb15eeb70..1a9bc9ae04 100644 --- a/be/src/common/status.h +++ b/be/src/common/status.h @@ -479,7 +479,7 @@ private: #endif }; std::unique_ptr _err_msg; - std::string _be_ip = BackendOptions::get_localhost(); + std::string_view _be_ip = BackendOptions::get_localhost(); }; inline std::ostream& operator<<(std::ostream& ostr, const Status& status) { diff --git a/be/src/service/backend_options.cpp b/be/src/service/backend_options.cpp index 5a431a2827..bad73b0c82 100644 --- a/be/src/service/backend_options.cpp +++ b/be/src/service/backend_options.cpp @@ -86,7 +86,7 @@ bool BackendOptions::init() { return true; } -std::string BackendOptions::get_localhost() { +const std::string& BackendOptions::get_localhost() { return _s_localhost; } diff --git a/be/src/service/backend_options.h b/be/src/service/backend_options.h index fc7c2ea5a4..5d28edbf12 100644 --- a/be/src/service/backend_options.h +++ b/be/src/service/backend_options.h @@ -29,7 +29,7 @@ class CIDR; class BackendOptions { public: static bool init(); - static std::string get_localhost(); + static const std::string& get_localhost(); static bool is_bind_ipv6(); static const char* get_service_bind_address();