mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
3e640489bd
* compile/compile_bench_test: Add basic compilation benchmark. * types/types: Replace linear copy loops with copy() Go builtin. * types/types: Switch linear scan -> binary search. This commit switches out the linear scan in the `Any` type's `Contains` method for a more efficient binary search. This results in around a 3-5x speedup for policy compilation as a whole, according to the benchmark. * ast/visit: Remove for loop item copies. This commit refactors the visitor functions in the `ast/visit` package to avoid extra copying of items on each loop iteration. This shaves off around 10-15% memory usage during type-checking during compilation, and provides speed benefits due to reduced GC as a result. Signed-off-by: Philip Conrad <philipaconrad@gmail.com>