cedar-policy / cedar

Implementation of the Cedar Policy Language
https://www.cedarpolicy.com
Apache License 2.0
892 stars 80 forks source link

Tweak constructor to avoid re-building attrs Map #1230

Closed john-h-kastner-aws closed 2 months ago

john-h-kastner-aws commented 2 months ago

Description of changes

Fix #540

Avoid building a map twice in some cases by having the constructor take an impl IntoIterator<Item = (SmolStr, PartialValue)> instead of HashMap. There also already exists new_with_attr_partial_value_serialized_as_expr which can be called to avoid re-building when the attrs are already a BTreeMap.

Issue #, if available

Checklist for requesting a review

The change in this PR is (choose one, and delete the other options):

I confirm that this PR (choose one, and delete the other options):

I confirm that cedar-spec (choose one, and delete the other options):

I confirm that docs.cedarpolicy.com (choose one, and delete the other options):