Skip to content

Conversation

@valadaptive
Copy link

The Expression type seems to have gotten quite large: it's currently 600 bytes. This PR reduces that to 240 bytes via the following:

  • LicenseId and ExceptionId now only store the index. All the metadata is static so we can look it up as necessary. name, full_name, and flags have been changed to getter methods to accommodate this. This brings their size down from 48 bytes to 8 bytes. Reducing the size of the index type is unlikely to bring any further benefit, since these types are stored in enums that have variants just as large.
  • The external document reference variants in AdditionItem and LicenseItem have been boxed, since I don't expect them to be very common. This brings AdditionItem and LicenseItem down from 56 bytes to 16. They could be 8 bytes if Rust learns to optimize them better. This in turn takes LicenseReq from 104 bytes to 32.

Tuning the SmallVec capacity might be something to look into in the future; I suspect most Rust crates use MIT OR Apache-2.0 and hence a capacity of 3 would work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant