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

Fix clippy error: slow zero-filling initialization #70

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

obbardc
Copy link
Contributor

@obbardc obbardc commented Jan 10, 2024

Clippy produces an error:

error: slow zero-filling initialization
Error:   --> bmap-parser/src/lib.rs:62:5
   |
60 |     let mut v = Vec::new();
   |                 ---------- help: consider replacing this with: `vec![0; 8 * 1024 * 1024]`
61 |     // TODO benchmark a reasonable size for this
62 |     v.resize(8 * 1024 * 1024, 0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: slow zero-filling initialization
Error:    --> bmap-parser/src/lib.rs:109:5
    |
107 |     let mut v = Vec::new();
    |                 ---------- help: consider replacing this with: `vec![0; 8 * 1024 * 1024]`
108 |     // TODO benchmark a reasonable size for this
109 |     v.resize(8 * 1024 * 1024, 0);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Fix it by following the suggestions.

Clippy produces an error:

    error: slow zero-filling initialization
    Error:   --> bmap-parser/src/lib.rs:62:5
       |
    60 |     let mut v = Vec::new();
       |                 ---------- help: consider replacing this with: `vec![0; 8 * 1024 * 1024]`
    61 |     // TODO benchmark a reasonable size for this
    62 |     v.resize(8 * 1024 * 1024, 0);
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    error: slow zero-filling initialization
    Error:    --> bmap-parser/src/lib.rs:109:5
        |
    107 |     let mut v = Vec::new();
        |                 ---------- help: consider replacing this with: `vec![0; 8 * 1024 * 1024]`
    108 |     // TODO benchmark a reasonable size for this
    109 |     v.resize(8 * 1024 * 1024, 0);
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Fix it by following the suggestions.

Signed-off-by: Christopher Obbard <[email protected]>
@obbardc obbardc added this pull request to the merge queue Jan 10, 2024
Merged via the queue into main with commit 5f487d2 Jan 10, 2024
8 checks passed
@obbardc obbardc deleted the wip/obbardc/fix-clippy branch January 10, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant