Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pmtiles/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ func SerializeEntries(entries []EntryV3, compression Compression) []byte {
}

func DeserializeEntries(data *bytes.Buffer, compression Compression) []EntryV3 {
entries := make([]EntryV3, 0)

var reader io.Reader

if compression == NoCompression {
Expand All @@ -338,6 +336,10 @@ func DeserializeEntries(data *bytes.Buffer, compression Compression) []EntryV3 {

numEntries, _ := binary.ReadUvarint(byteReader)

// Preallocate the entries slice to the known count so the append loops below
// do not repeatedly reallocate and copy the backing array as it grows.
entries := make([]EntryV3, 0, numEntries)

lastID := uint64(0)
for i := uint64(0); i < numEntries; i++ {
tmp, _ := binary.ReadUvarint(byteReader)
Expand Down
Loading