Skip to content
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

Optimize wildcard search executions #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jlourenc
Copy link

@jlourenc jlourenc commented Nov 5, 2021

This PR makes wildcard searches significantly faster by reducing heap allocations where possible.

searchStrict logic has been encapsulated in a function that returns interface{} instead of *Container as the first returned parameter. This avoids the unnecessary wrapping/unwrapping.

Also, when handling a wildcard as the last path segment, array values are no longer copied. Instead the array is returned directly and then wrapped in a Container. This removes another allocation.

BenchmarkWildcardSearch has been added to assess the improvements.

Before the change:

BenchmarkWildcardSearch-16 2838511 413.2 ns/op 240 B/op 12 allocs/op

After the change:

BenchmarkWildcardSearch-16 5705732 201.8 ns/op 112 B/op 5 allocs/op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant