Skip to content

Commit 72e1aca

Browse files
committed
instream: pass fileName by reference
... to eliminate unnecessary string copies Suggested by Coverity: ``` Error: COPY_INSTEAD_OF_MOVE: src/cslinker.cc:236:29: copy_constructor_call: "fnCwe" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const &)", when it could be moved instead. src/cslinker.cc:236:29: remediation: Use "std::move(""fnCwe"")" instead of "fnCwe". Error: COPY_INSTEAD_OF_MOVE: src/cslinker.cc:249:29: copy_constructor_call: "fnImp" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const &)", when it could be moved instead. src/cslinker.cc:249:29: remediation: Use "std::move(""fnImp"")" instead of "fnImp". ``` Related: #216
1 parent 703c2f5 commit 72e1aca

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

src/lib/instream.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
#include "instream.hh"
2121

22-
InStream::InStream(std::string fileName, const bool silent):
23-
fileName_(std::move(fileName)),
22+
InStream::InStream(const std::string &fileName, const bool silent):
23+
fileName_(fileName),
2424
silent_(silent),
2525
str_((fileName_ == "-")
2626
? std::cin

src/lib/instream.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct InFileException {
3838

3939
class InStream {
4040
public:
41-
InStream(std::string fileName, bool silent = false);
41+
InStream(const std::string &fileName, bool silent = false);
4242
InStream(std::istringstream &str, bool silent = false);
4343
~InStream() = default;
4444

src/lib/parser-json-cov.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,3 @@ bool CovTreeDecoder::readNode(Defect *def)
8989

9090
return true;
9191
}
92-

0 commit comments

Comments
 (0)