JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
85 stars 3 forks source link

Use writer wherever possible instead of creating a new string each time #282

Closed JSAbrahams closed 2 years ago

JSAbrahams commented 2 years ago

Current Issue

In multiple locations, we often use format! instead of write!. The former consumes a lot of resources since we're constantly creating new strings, whereas the writer writes to some writable directly. Not sure if this will make a major difference performance wise (like, a speedup of a few ms is not groundbreaking), but still more elegant. It's what Clippy keeps pointing out as well.

Description of potential implementation

Use write! where possible (and where it doesn't create a lot of extra code noise) and pass a writeable as argument, or create it locally. This is somewhat similar to using a StringBuilder in Java (it's the only example I have handy at the moment).

JSAbrahams commented 2 years ago

Too vague, and already appears to be the case.