[SERVER-29447] Transition away from Java-style `std::string toString() const` member functions Created: 05/Jun/17 Updated: 06/Dec/22 Resolved: 24/Jun/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | ADAM Martin (Inactive) | Assignee: | DO NOT USE - Backlog - Dev Tools |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Developer Tools
|
||||||||
| Participants: | |||||||||
| Description |
|
Such a design creates numerous superfluous temporaries. Even with short-string optimizations, eventually the composition of such temporaries creates temporaries whose length exceeds that of of the short-string space. This starts to put undue pressure on the allocator. In C++ the right equivalent to `toString()` for output composition is the `std::ostream &operator << ( std::ostream &, const T & )` overload which is ADL-found at use. If temporary strings are needed, `std::stringstream` can be used. Additionally, `str::stream()` exists in our code base. |