mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
Use std::string_view in EventLogger
Change-Id: If23504e146826f143220b031a5fbc2be2013d127
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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_;
|
||||
|
||||
Reference in New Issue
Block a user