From 719b1fb24fd317b26a4eb019f00ebde0ebd4c8ce Mon Sep 17 00:00:00 2001 From: Vlad Zolotarov Date: Tue, 20 Jun 2017 14:56:18 -0400 Subject: [PATCH] db::commitlog::descriptor::descriptor(filename): pass a filename as a const ref Avoid not needed copy by passing a file name as a reference. Signed-off-by: Vlad Zolotarov --- db/commitlog/commitlog.cc | 4 ++-- db/commitlog/commitlog.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index c9334a657e..e88de49277 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -132,8 +132,8 @@ db::commitlog::descriptor::descriptor(std::pair p) : descriptor(p.first, p.second) { } -db::commitlog::descriptor::descriptor(sstring filename) - : descriptor([filename]() { +db::commitlog::descriptor::descriptor(const sstring& filename) + : descriptor([&filename] () { std::smatch m; // match both legacy and new version of commitlogs Ex: CommitLog-12345.log and CommitLog-4-12345.log. std::regex rx("(?:.*/)?" + FILENAME_PREFIX + "((\\d+)(" + SEPARATOR + "\\d+)?)" + FILENAME_EXTENSION); diff --git a/db/commitlog/commitlog.hh b/db/commitlog/commitlog.hh index d02c60bf1e..c7946210ba 100644 --- a/db/commitlog/commitlog.hh +++ b/db/commitlog/commitlog.hh @@ -139,7 +139,7 @@ public: descriptor(const descriptor&) = default; descriptor(segment_id_type i, uint32_t v = 1); descriptor(replay_position p); - descriptor(sstring filename); + descriptor(const sstring& filename); sstring filename() const; operator replay_position() const;