Skip to content

Commit

Permalink
Merge pull request #26 from paulmach/no-preallocate
Browse files Browse the repository at this point in the history
osmpbf: do not preallocate nodes
  • Loading branch information
paulmach authored Apr 27, 2021
2 parents 497f4f3 + fcd8141 commit 9df5be8
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions osmpbf/decode_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,12 @@ func (dec *dataDecoder) extractDenseNodes() error {
latOffset := dec.primitiveBlock.GetLatOffset()
lonOffset := dec.primitiveBlock.GetLonOffset()

// we also assume all the iterators have the same length....

nodes := make([]osm.Node, dec.versions.Count(protoscan.WireTypeVarint))

var id, lat, lon, timestamp, changeset int64
var uid, usid int32
var index int
for dec.versions.HasNext() {
n := &nodes[index]
n.Visible = true
index++
// NOTE: do not try pre-allocating an array of nodes because saving
// just one will stop the GC from cleaning up the whole pre-allocated array.
n := &osm.Node{Visible: true}

// ID
v1, err := dec.ids.Sint64()
Expand Down

0 comments on commit 9df5be8

Please sign in to comment.