Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Size Optimization: Capture root varaiable if it's a sharef ref #49

Open
@arora-aman

Description

@arora-aman

Initial thoughts:

  • If the root variable is a shared ref then any path starting at that root variable will be captured by ref or copied (in case the path is Copy and the closure is a move closure)

  • We will never have a borrow conflict if we reduce the precision

  • In the case where the path would've been captured by ref, truncating to the root variable and capturing the root variable will result in capture of the same size or maybe cheaper.

    • It's cheaper in case of function pointers. Right now the way preicse capture analysis would capture f: &F works is we caputre &*f which ends up capturing a fat pointer which is two words. Before precise capture we'd capture &f which is a thin pointer and a single word.
  • In the case where the path would've been copied, truncating to the root variable can possibly result increase in size compared to precise capture.

    • eg: Consider x: &T, x.y: u8 then it's cheaper to copy x.y is cheaper than copying x

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions