Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

ExpressionKind members have large size differences #200

Closed
yoshuawuyts opened this issue Oct 12, 2020 · 0 comments
Closed

ExpressionKind members have large size differences #200

yoshuawuyts opened this issue Oct 12, 2020 · 0 comments
Labels
kind/improvement An improvement to existing feature and code.
Milestone

Comments

@yoshuawuyts
Copy link
Contributor

Function(Function<'a>),
and
Query(Select<'a>),
are marked by clippy as 500 bytes, with the second-largest member being 40 bytes. Adding an intermediate box will likely help improve allocations / performance.

You can get this output by running:

$ cargo +nightly clippy

Thanks!

Output

warning: large size difference between variants
   --> src\ast\expression.rs:170:5
    |
170 |     Function(Function<'a>),
    |     ^^^^^^^^^^^^^^^^^^^^^^ this variant is 536 bytes
    |
    = note: `#[warn(clippy::large_enum_variant)]` on by default
note: and the second-largest variant is 40 bytes:
   --> src\ast\expression.rs:162:5
    |
162 |     RawValue(Raw<'a>),
    |     ^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
    |
170 |     Function(Box<Function<'a>>),
    |              ^^^^^^^^^^^^^^^^^

warning: large size difference between variants
  --> src\ast\table.rs:22:5
   |
22 |     Query(Select<'a>),
   |     ^^^^^^^^^^^^^^^^^ this variant is 296 bytes
   |
note: and the second-largest variant is 32 bytes:
  --> src\ast\table.rs:21:5
   |
21 |     Table(Cow<'a, str>),
   |     ^^^^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
   |
22 |     Query(Box<Select<'a>>),
   |           ^^^^^^^^^^^^^^^
@yoshuawuyts yoshuawuyts added the kind/improvement An improvement to existing feature and code. label Oct 12, 2020
@yoshuawuyts yoshuawuyts added this to the 2.17.0 milestone Feb 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/improvement An improvement to existing feature and code.
Projects
None yet
Development

No branches or pull requests

1 participant