-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid re-compiling rules #20
Comments
I independently noticed the same thing while working on ccbbeee and attempted to improve it, but since performace wasn't my main motivation in that commit I didn't spend much time studying the impact of the change I attempted there. Looking back at it again with fresh eyes today I suspect I may not have actually fully addressed it: @skeggse's note about passing by reference instead of by value makes me notice that I seem to have made it just ineffectually precompile copies of the default rules, rather than the actual values that end up in the default ruleset: go-slug/internal/ignorefiles/terraformignore.go Lines 161 to 186 in 6a7ca7a
A small change that might make it effectual is to refer directly to the array elements by index, rather than working on the copies that the for i := range defaultExclusions {
err := defaultExclusions[i].compile()
if err != nil {
panic(fmt.Sprintf("invalid default rule %q: %s", r.val, err))
}
} The default match object includes a slice value covering the same backing array, so I expect that a change like the above would make it effective, but I've not yet tested. |
@brandonc i don't suppose you looked at this issue while you were working on the directory issue? |
I observed, while looking into #19, that due to the current implementation we're actually re-compiling every rule for every file. Updating the
range
inmatchIgnoreRule
to be by-reference improves performance on large repositories by a factor of ~3.The text was updated successfully, but these errors were encountered: