Use std::string_view to construct dbus::ObjectPath
This change improves the efficiency of dbus::ObjectPath constructor
call sites which typically invoke this method with a compile-time
constant.
Change-Id: I8173894ae31939f9864e607b48086564806f229c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6036254
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1385724}
NOKEYCHECK=True
GitOrigin-RevId: 6576fc650c070d503f42640c3004fec4f49ce80c
diff --git a/object_path.h b/object_path.h
index 0b99e4f..3708c84 100644
--- a/object_path.h
+++ b/object_path.h
@@ -7,6 +7,7 @@
#include <iosfwd>
#include <string>
+#include <string_view>
#include "dbus/dbus_export.h"
@@ -23,10 +24,10 @@
// objects.
//
// The compiler synthesised copy constructor and assignment operator are
- // sufficient for our needs, as is implicit initialization of a std::string
- // from a string constant.
- ObjectPath() {}
- explicit ObjectPath(const std::string& value) : value_(value) {}
+ // sufficient for our needs, as is implicit initialization of a
+ // std::string_view from a string constant.
+ ObjectPath() = default;
+ explicit ObjectPath(std::string_view value) : value_(value) {}
// Retrieves value as a std::string.
const std::string& value() const { return value_; }