[Xapian-tickets] [Xapian] #140: Pass strings as "const std::string &" not "std::string" (was: Benchmark if passing "const std::string &" or just "std::string" is better)

Xapian nobody at xapian.org
Tue May 19 15:46:45 BST 2009


#140: Pass strings as "const std::string &" not "std::string"
-------------------------+--------------------------------------------------
 Reporter:  olly         |        Owner:  olly     
     Type:  enhancement  |       Status:  assigned 
 Priority:  lowest       |    Milestone:  1.1.1    
Component:  Other        |      Version:  SVN trunk
 Severity:  minor        |   Resolution:           
 Keywords:               |    Blockedby:           
 Platform:  All          |     Blocking:           
-------------------------+--------------------------------------------------
Changes (by olly):

  * owner:  nobody => olly
  * status:  new => assigned
  * milestone:  1.1.7 => 1.1.1


Comment:

 OK, I've just microbenchmarked this for GCC 4.3.3 on x86-64 Ubuntu jaunty
 and {{{const std::string &}}} parameters are a little faster than
 {{{std::string}}} ones.  Also, looking at the generated assembler shows
 it's more compact too!

 So this bug can become "fix passing std::string by value to pass by const
 ref instead".

 Marking for 1.1.1, as I don't think there are many of these and they
 should be grep-able.

-- 
Ticket URL: <http://trac.xapian.org/ticket/140#comment:8>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list