[go: up one dir, main page]

MIR: use reference counting in Type

Context

Changes Box for Rc in Type. The motivation is to make cloning types cheaper. We have got by without doing too many expensive clones so far, but with lambdas this got a little out of hand, so might as well do this now.

This makes Type::clone() O(1) instead of O(n) (because now instead of recursively cloning all Boxes it just needs to bump at most one Rc counter), at the cost of requiring a bit more (now O(1)) cloning in the typechecker. This is a tradeoff, but it's one we intended to make eventually anyway.

A possible alternative is to use an arena for Type allocations, and it would be a bit faster, as it wouldn't require reference counting, but that change would be a lot more invasive than this. We can revisit this idea if we have time later.

I consider this part of #6620 (closed)

Based on: !10984 (merged)

Manually testing the MR

cargo test. This is a refactoring MR.

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR

Merge request reports

Loading