spruce icon indicating copy to clipboard operation
spruce copied to clipboard

Implement some best practices, fix error in static_ips test & avoid excessive regex calls when line is not spruce line

Open adberger opened this issue 1 year ago • 1 comments

Hi there

I've made a few changes, the biggest one being the matchPattern function which should make spruce much faster especially when rendering larges files.

If you are open to a review (& possible merge), I ask you to do it thoroughly as I don't have much experience with Go.

Here is a benchmark comparsion from our tool, which uses spruce under the hood:

Before:

BenchmarkExecute-12            1        8906495459 ns/op        65408706864 B/op        679075642 allocs/op
PASS
ok      github.com/bedag/subst/subst/cmd        9.524s

After:

BenchmarkExecute-12            1        1447321000 ns/op        1864258368 B/op 20667868 allocs/op
PASS
ok      github.com/bedag/subst/subst/cmd        2.065s

Memory consumption went down from ~60GB to ~1GB, so much less garbage collection.

adberger avatar Oct 21 '24 13:10 adberger

@geofffranks Do you consider reviewing & merging this? :)

adberger avatar Nov 06 '24 13:11 adberger