mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-18 22:41:00 -06:00
47a13c4f8c
This commit adds a new `EditTree` data structure, which is built for applying in-place modifications to a Term, and can render the final result of all the edits efficiently. The goal is to use this data structure to apply *all* of the patches in a JSON-Patch sequence rapidly, and then collapse all of the edits at the end with minimal wasted Term copying. The `EditTree` data structure supports the following core operations: - Insert - Delete - Unfold - Render It is designed to work across all core Rego data types, with special- case handling for scalars versus composite types. It also vendors in a bit-vector library to allow for ease-of- bookkeeping for in-place Array modifications. As an example of usage, `json.filter`'s builtin implementation has been replaced with an `EditTree`-based design, which scales well on deeply-nested paths, relative to the original implementation. Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
This is a Go package for manipulating paragraphs of text. See http://go.pkgdoc.org/github.com/kr/text for full documentation.