[cfe-commits] r108375 - in /cfe/trunk: include/clang/Basic/FileManager.h include/clang/Rewrite/Rewriter.h lib/Basic/FileManager.cpp lib/Checker/LLVMConventionsChecker.cpp lib/Frontend/PCHReader.cpp lib/Rewrite/Rewriter.cpp

Fariborz Jahanian fjahanian at apple.com
Thu Jul 15 09:42:44 PDT 2010


On Jul 15, 2010, at 9:34 AM, Chris Lattner wrote:

>
> On Jul 15, 2010, at 9:27 AM, Fariborz Jahanian wrote:
>>
>> I don't seem to see the rational for changing const llvm::StringRef &
>> to StringRefs by value.
>
> It's a (very small) performance win.  StringRef is a pair (pointer  
> +length).  Passing it by value (e.g. on x86-64) causes it to be  
> passed in two registers.  Passing it by reference passes the  
> address, requiring the callee to dereference it and pinning it to  
> the stack in the caller.

Makes sense; no copy construction is involved here.

- Thanks, Fariborz

>
>
> -Chris




More information about the cfe-commits mailing list