You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KCL: Mostly reuse one string buffer in recaster (#7869)
Before this PR, most of the recast functions looked like this
```
fn recast(&self, options, indentation_level) -> String
```
In other words, when they ran, they allocated and returned a string. This mean every function would perform at least 1 allocation.
Now they generally look like this:
```
fn recast(&self, buf: &mut String, options, indentation_level)
```
In other words, they usually accept a string from the caller and append to it, rather than allocating a new one. This reduces allocations (because generally the same single string can be shared across recasts) which saves time (because a huge portion of recast time was just allocating strings, appending their contents to some other string, then dropping it).
On my Macbook, this cuts down the recast benchmarks by 55-65%.
0 commit comments