Skip to content

Commit

Permalink
Merge pull request #16 from multiversx/improve-slice-allocation
Browse files Browse the repository at this point in the history
Improve slice allocation by specifying the capacity.
  • Loading branch information
AdoAdoAdo authored Aug 26, 2024
2 parents 8f76917 + 1f29ce0 commit ab42226
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion process/dataAggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"

"github.com/multiversx/mx-chain-ws-connector-firehose-go/data/hyperOutportBlocks"

data "github.com/multiversx/mx-chain-ws-connector-firehose-go/data/hyperOutportBlocks"
Expand Down Expand Up @@ -38,7 +39,7 @@ func (da *dataAggregator) ProcessHyperBlock(metaOutportBlock *hyperOutportBlocks
hyperOutportBlock := &data.HyperOutportBlock{}
hyperOutportBlock.MetaOutportBlock = metaOutportBlock

notarizedShardOutportBlocks := make([]*data.NotarizedHeaderOutportData, 0)
notarizedShardOutportBlocks := make([]*data.NotarizedHeaderOutportData, 0, len(metaOutportBlock.NotarizedHeadersHashes))

log.Info("dataAggregator: notarizedHashes", "block hash", metaOutportBlock.BlockData.HeaderHash,
"num notarizedHashes", len(metaOutportBlock.NotarizedHeadersHashes))
Expand Down
4 changes: 2 additions & 2 deletions process/outportBlockConverter.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (o *outportBlockConverter) HandleShardOutportBlock(outportBlock *outport.Ou
return nil, fmt.Errorf("failed to unmarshal: %w", err)
}

miniBlockHeaders := make([]*hyperOutportBlocks.MiniBlockHeader, 0)
miniBlockHeaders := make([]*hyperOutportBlocks.MiniBlockHeader, 0, len(header.Header.MiniBlockHeaders))
for _, miniBlockHeader := range header.Header.MiniBlockHeaders {
mb := &hyperOutportBlocks.MiniBlockHeader{
Hash: miniBlockHeader.Hash,
Expand All @@ -431,7 +431,7 @@ func (o *outportBlockConverter) HandleShardOutportBlock(outportBlock *outport.Ou
miniBlockHeaders = append(miniBlockHeaders, mb)
}

peerChanges := make([]*hyperOutportBlocks.PeerChange, 0)
peerChanges := make([]*hyperOutportBlocks.PeerChange, 0, len(header.Header.PeerChanges))
for _, peerChange := range header.Header.PeerChanges {
pc := &hyperOutportBlocks.PeerChange{
PubKey: peerChange.PubKey,
Expand Down

0 comments on commit ab42226

Please sign in to comment.