Use std::string_view in EventLogger

Change-Id: If23504e146826f143220b031a5fbc2be2013d127
This commit is contained in:
Sameer Agarwal
2024-09-28 15:12:23 -07:00
parent 01a06ef7b1
commit 3db40b8013
2 changed files with 6 additions and 4 deletions
+3 -2
View File
@@ -31,6 +31,7 @@
#include "ceres/event_logger.h"
#include <string>
#include <string_view>
#include "absl/log/log.h"
#include "absl/log/vlog_is_on.h"
@@ -40,7 +41,7 @@
namespace ceres::internal {
EventLogger::EventLogger(const std::string& logger_name)
EventLogger::EventLogger(std::string_view logger_name)
: start_time_(absl::Now()) {
if (!VLOG_IS_ON(3)) {
return;
@@ -60,7 +61,7 @@ EventLogger::~EventLogger() {
VLOG(3) << "\n" << events_ << "\n";
}
void EventLogger::AddEvent(const std::string& event_name) {
void EventLogger::AddEvent(std::string_view event_name) {
if (!VLOG_IS_ON(3)) {
return;
}
+3 -2
View File
@@ -32,6 +32,7 @@
#define CERES_INTERNAL_EVENT_LOGGER_H_
#include <string>
#include <string_view>
#include "absl/time/time.h"
#include "ceres/internal/disable_warnings.h"
@@ -65,9 +66,9 @@ namespace ceres::internal {
// Total: time3 time1 + time2 + time3;
class CERES_NO_EXPORT EventLogger {
public:
explicit EventLogger(const std::string& logger_name);
explicit EventLogger(std::string_view logger_name);
~EventLogger();
void AddEvent(const std::string& event_name);
void AddEvent(std::string_view event_name);
private:
const absl::Time start_time_;