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

Improve slice allocation by specifying the capacity. #16

Merged
merged 13 commits into from
Aug 26, 2024

Conversation

cristure
Copy link

While initializing a slice using make, we saw that we have to provide a length and an optional capacity. Forgetting to pass an appropriate value for both of these parameters when it makes sense is a widespread mistake.

Comment on lines 40 to 41
n := len(outportBlock.NotarizedHeadersHashes)
notarizedShardOutportBlocks := make([]*data.NotarizedHeaderOutportData, 0, n)
Copy link

Choose a reason for hiding this comment

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

optinal, more like a preference thing: suggestion to use len(...) directly instead of setting n variable

ssd04
ssd04 previously approved these changes Apr 24, 2024
…to improve-slice-allocation

# Conflicts:
#	process/dataAggregator.go
#	process/outportBlockConverter.go
ssd04
ssd04 previously approved these changes Apr 26, 2024
@AdoAdoAdo AdoAdoAdo merged commit ab42226 into feat/hyperblock Aug 26, 2024
3 checks passed
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