[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:
Related
related to SERVER-29360 Add operator<< to Date_t class Closed
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.


Generated at Thu Feb 08 04:20:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.