Skip to content

Comments

Optimize wildcard search executions#115

Open
jlourenc wants to merge 1 commit intoJeffail:masterfrom
jlourenc:optimize_wildcard_search_execution
Open

Optimize wildcard search executions#115
jlourenc wants to merge 1 commit intoJeffail:masterfrom
jlourenc:optimize_wildcard_search_execution

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.

1 participant