> Two choices have been mentioned. One is > 1) void function(std::string); > 2) void function(const std::string&); > > In my professional experience, we usually pass a structure by reference when > it can't fit in a register. We always use (2) with strings that the function > will not modify. We also pass smart pointers by const reference when the > function will not create new references to the pointee.
The patch is ready. All tests pass. 83 files changed, 248 insertions(+), 254 deletions(-) There is no significant time improvement with it. I wait for another patch to be pushed (if accepted) before commiting to ritveld because both patches interact. Then a discussion can start but if David says no, I'd better just not submit the patch. It has still been useful helping me to go inside lilypond. > The other choice is > > 3) std::string getSomeMember() const; > 4) const std::string& getSomeMember() const; > > Reasonable people might disagree, but IMHO this is premature optimization. > It is better to use (3), trust the compiler to do return value optimization, > and wait for profiling to prove that there is any problem. I share David's > concern that (4) can lead to bugs, and as above, not having to worry about > those details frees a contributor to focus on the goal. I can understand this. Frédéric _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel