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
main
Yanqin Jin 6 years ago committed by Facebook Github Bot
parent f60c4e5a58
commit ce52274640
  1. 3
      include/rocksdb/listener.h
  2. 6
      util/file_reader_writer.h

@ -144,12 +144,13 @@ struct TableFileDeletionInfo {
}; };
struct FileOperationInfo { struct FileOperationInfo {
std::string path; const std::string& path;
uint64_t offset; uint64_t offset;
size_t length; size_t length;
time_t start_timestamp; time_t start_timestamp;
time_t finish_timestamp; time_t finish_timestamp;
Status status; Status status;
FileOperationInfo(const std::string& _path) : path(_path) {}
}; };
struct FlushJobInfo { struct FlushJobInfo {

@ -66,8 +66,7 @@ class RandomAccessFileReader {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
void NotifyOnFileReadFinish(uint64_t offset, size_t length, time_t start_ts, void NotifyOnFileReadFinish(uint64_t offset, size_t length, time_t start_ts,
const Status& status) const { const Status& status) const {
FileOperationInfo info; FileOperationInfo info(file_name_);
info.path = file_name_;
info.offset = offset; info.offset = offset;
info.length = length; info.length = length;
info.start_timestamp = start_ts; info.start_timestamp = start_ts;
@ -160,8 +159,7 @@ class WritableFileWriter {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
void NotifyOnFileWriteFinish(uint64_t offset, size_t length, time_t start_ts, void NotifyOnFileWriteFinish(uint64_t offset, size_t length, time_t start_ts,
const Status& status) { const Status& status) {
FileOperationInfo info; FileOperationInfo info(file_name_);
info.path = file_name_;
info.offset = offset; info.offset = offset;
info.length = length; info.length = length;
info.start_timestamp = start_ts; info.start_timestamp = start_ts;

Loading…
Cancel
Save