llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.68k stars 10.92k forks source link

clang/include/clang/Interpreter/Interpreter.h:53: Small performance issue ? #94105

Open dcb314 opened 4 weeks ago

dcb314 commented 4 weeks ago

Static analyser cppcheck says:

clang/include/clang/Interpreter/Interpreter.h:53:36: performance: Function parameter 'TT' should be passed by const reference. [passedByValue]

Source code is

void SetTargetTriple(std::string TT) { TargetTriple = TT; }

Maybe better code:

void SetTargetTriple( const std::string & TT ) { TargetTriple = TT; }

jroelofs commented 4 weeks ago

llvm has its own type for this, which should be used instead of const std::string &, namely llvm::StringRef