3 ms·
I'm wonder what this mysterious application is that is doing heavy formatting of strings but can't afford the overhead of a temporary string, and therefore requ
by rerdavies 2y ago
I'm wonder what this mysterious application is that is doing heavy formatting of strings but can't afford the overhead of a temporary string, and therefore requires horrifying and inscrutable and dangerous language extensions.
- chlorion 2y agoBeing able to use string formatting without a heap is pretty cool. Rusts string formatting machinery does not require any heap allocations at all, you can for example impl fmt::Write for a struct that writes directly to a serial console byte-by-byte with no allocations, and then you have access to all of rusts string formatting features available to print over a serial console! I'm not sure about the horrifying and dangerous extensions part though, I'm not really a C++ expert so I don't know if there's a better way to do what they want to do.
- badmintonbaseba 2y agofreestanding maybe? Embedded apps often don't shy away from using something like printf, yet they don't like unnecessary allocations.
- gpderetta 2y agoFor example, an high performance logger can ship the tuple object to a background thread for actual formatting and I/O, after converting the capture to by-value. Formatting on the foreground thread would be a non-starter.