internal+json.filter: Add EditTree data structure. (#5494)
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>
P
Philip Conrad committed
47a13c4f8c6cbb68c219252ad58ae8afa6325078
Parent: 8df850e
Committed by GitHub <noreply@github.com>
on 2/14/2023, 8:30:59 PM