Pass strings as "const std::string &" not "std::string"
Most modern compilers seem to implement std::string using PIMPL, so the class is
just a single pointer and pass-by-value may be more efficient.
MSVC is the notable exception I'm currently aware of. Macro magic is one
possible solution. Or perhaps benchmarking will reveal moving helps non-MSVC
without penalising MSVC much.
Either way, most of the library passes by const ref, but some of the internals
pass by value, and we should standardise!
Change History
(9)
| Blocking: |
160 added; 120 removed
|
| Operating System: |
→ All
|
| Description: |
modified (diff)
|
| Milestone: |
→ 1.1
|
| Milestone: |
1.1.7 → 1.1.1
|
| Owner: |
changed from Not currently assigned to Olly Betts
|
| Status: |
new → assigned
|
| Summary: |
Benchmark if passing "const std::string &" or just "std::string" is better → Pass strings as "const std::string &" not "std::string"
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
| Milestone: |
1.1.1 → 1.0.13
|
We're certainly not going to change the internals of 1.0.x in such a sweeping way at this point, but it would be worth benchmarking this before 1.1.0 if we can.