From ce522746406f9e37e892c2709b51c67640b0491f Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Mon, 15 Oct 2018 13:43:53 -0700 Subject: [PATCH] Replace 'string' with 'const string&' in FileOperationInfo (#4491) Summary: Using const string& can avoid one extra string copy. This PR addresses a recent comment made by siying on #3933. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4491 Differential Revision: D10381211 Pulled By: riversand963 fbshipit-source-id: 27fc2d65d84bc7cd07833c77cdc47f06dcfaeb31 --- include/rocksdb/listener.h | 3 ++- util/file_reader_writer.h | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/rocksdb/listener.h b/include/rocksdb/listener.h index e61410c85..8ceb2ed4c 100644 --- a/include/rocksdb/listener.h +++ b/include/rocksdb/listener.h @@ -144,12 +144,13 @@ struct TableFileDeletionInfo { }; struct FileOperationInfo { - std::string path; + const std::string& path; uint64_t offset; size_t length; time_t start_timestamp; time_t finish_timestamp; Status status; + FileOperationInfo(const std::string& _path) : path(_path) {} }; struct FlushJobInfo { diff --git a/util/file_reader_writer.h b/util/file_reader_writer.h index f73383080..f6b0c7bcb 100644 --- a/util/file_reader_writer.h +++ b/util/file_reader_writer.h @@ -66,8 +66,7 @@ class RandomAccessFileReader { #ifndef ROCKSDB_LITE void NotifyOnFileReadFinish(uint64_t offset, size_t length, time_t start_ts, const Status& status) const { - FileOperationInfo info; - info.path = file_name_; + FileOperationInfo info(file_name_); info.offset = offset; info.length = length; info.start_timestamp = start_ts; @@ -160,8 +159,7 @@ class WritableFileWriter { #ifndef ROCKSDB_LITE void NotifyOnFileWriteFinish(uint64_t offset, size_t length, time_t start_ts, const Status& status) { - FileOperationInfo info; - info.path = file_name_; + FileOperationInfo info(file_name_); info.offset = offset; info.length = length; info.start_timestamp = start_ts;