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: fix slice init length #919

Closed
wants to merge 1 commit into from
Closed

Conversation

cuishuang
Copy link

The intention here should be to initialize a slice with a capacity of 4 rather than initializing the length of this slice.

@dveeden
Copy link
Collaborator

dveeden commented Sep 28, 2024

Can you explain the issue you're trying to fix? Is this for functionality and/or performance?

If I understand this correctly it now appends to a slice of length 4 instead of filling a slice of length 0, but with a capacity of 4? Is this a regression? if so, what commit introduced this? Maybe we could/should add tests?

Looks like 4 is probably the wrong capacity in most cases. That's enough for the header, but not for the total packet. This is better than a capacity of 0, but a slightly larger capacity might be better. Some of these are dynamic, but some of these packets have a more predictable length.

@lance6716
Copy link
Collaborator

Hi, please fix ci

@dveeden
Copy link
Collaborator

dveeden commented Nov 8, 2024

@cuishuang could you fix the failing checks?

@cuishuang
Copy link
Author

@cuishuang could you fix the failing checks?

Sorry, it seems that my changes were incorrect. I found that my detection tool has a high false positive rate when the slice type is byte.

Sorry for wasting your time.

@cuishuang cuishuang closed this Nov 9, 2024
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.

3 participants