Skip to content

Set vec capcity to 1 by default - #422

Merged
gkorland merged 1 commit into
masterfrom
guyk-set-vec-capacity
Jul 8, 2021
Merged

gkorland merged 1 commit into
masterfrom
guyk-set-vec-capacity

Conversation

@gkorland

@gkorland gkorland commented Jul 7, 2021

Copy link
Copy Markdown
Contributor

No description provided.

@oshadmi oshadmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

Comment thread src/commands.rs

let mut paths: Vec<Path> = vec![];
// Set Capcity to 1 assumiung the common case has one path
let mut paths: Vec<Path> = Vec::with_capacity(1);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If indeed the common usage is a single path arg - we could benefit from this, since
Looking at raw_vec.rs, before this change, MIN_NON_ZERO_CAP would be 4 (since push will call reserve(1) when the initial len and capacity are zero in mod.rs)

@gkorland
gkorland merged commit 9610708 into master Jul 8, 2021
@gkorland
gkorland deleted the guyk-set-vec-capacity branch July 8, 2021 05:49
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.

2 participants