mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-21 01:37:15 +03:00
7ec55d7f33
Currently we have two implementations for the projection of structural record. 1- The first implementation takes as parameter the index of the projected field and is therefore constant. This implementations is used when the type checking is enable, as the index cannot be directly inferred from the AST and must hence be filled in by the DAML-LF type checker. 2- The second implementation takes as parameter the name of the projected field and is therefore logarithmic as the field must be lookup by binary search at each call. This version is used when the type checking is disable as the index cannot be inferred without type inference. In this PR, we modify the second implementation so it cache the index at the first call, hence avoiding the recomputation during further calls. In this way we reach an amortized constant complexity. The first implementation is decommissioned in benefit of the second one. The advantages of this approach are: - We have a unique implementation of the projection, so the behavior of a program is the same whenever the type checking is on or off. - The AST for structural projection is immutable. Benchmarks show no performance differences when the type checking is on. Based on an idea by @sofiafaro-da. CHANGELOG_BEGIN CHANGELOG_END |
||
---|---|---|
.. | ||
perf | ||
src | ||
BUILD.bazel |