Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shrink derive output size #2250

Closed

Commits on Jul 18, 2022

  1. Streamline the field count in serialize_struct calls.

    For a struct like this:
    ```
    struct Small {
        x: u32,
        y: u32,
        #[serde(skip_serializing_if = "Option::is_none")]
        maybe: Option<&'static str>,
    }
    ```
    it will change the field count computation from this:
    ```
    false as usize + 1 + 1 + if Option::is_none(&self.maybe) { 0 } else { 1 }
    ```
    to this:
    ```
    2usize + if Option::is_none(&self.maybe) { 0 } else { 1 }
    ```
    For fields with many fields, the difference will be bigger, avoiding long
    sequences of `1 + 1 + 1 + ...`. This is a small compile-time win.
    nnethercote committed Jul 18, 2022
    Configuration menu
    Copy the full SHA
    28493e9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    70213c0 View commit details
    Browse the repository at this point in the history

Commits on Jul 19, 2022

  1. Introduce next_element_checked to shorten output.

    This turns two matches into one, for each field in a struct.
    nnethercote committed Jul 19, 2022
    Configuration menu
    Copy the full SHA
    f872e17 View commit details
    Browse the repository at this point in the history
  2. Introduce next_value_checked to shorten output.

    This turns two matches into one, for each field in a struct.
    nnethercote committed Jul 19, 2022
    Configuration menu
    Copy the full SHA
    31f65f0 View commit details
    Browse the repository at this point in the history
  3. Introduce missing_value_checked to shorten output.

    This turns two matches into one, for each field in a struct.
    nnethercote committed Jul 19, 2022
    Configuration menu
    Copy the full SHA
    f8cc37c View commit details
    Browse the repository at this point in the history