0

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}
This commit is contained in:
Reilly Grant
2024-11-20 17:24:52 +00:00
committed by Chromium LUCI CQ
parent 6a1609e5af
commit 6576fc650c

@ -7,6 +7,7 @@
#include <iosfwd>
#include <string>
#include <string_view>
#include "dbus/dbus_export.h"
@ -23,10 +24,10 @@ class CHROME_DBUS_EXPORT ObjectPath {
// 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_; }