     }
 
     // MARK: - Private Properties
+
+    /** The number of slots to preallocate in a collection when we encounter the first value. */
+    private static let collectionPreallocationSlotCount = 5
+
+    /**
+     The maximum allowable value size for which we'll do collection preallocation.
+     If values in the collection are larger than this value then we won't preallocate.
+     */
+    private static let collectionPreallocationMaxValueSize = 128
 
     private let buffer: ReadBuffer
 

            throw ProtoDecoder.Error.mapEntryWithoutValue(key: key)
        }

        dictionary[unwrappedKey] = unwrappedValue
    }


            // than reallocate each time we add a new item. We'll use an arbitrary
            // (small) guess, and make sure we don't do this for large message
            // structs to avoid allocating too much extra memory.
            if array.isEmpty && MemoryLayout<T>.size <= ProtoReader.collectionPreallocationMaxValueSize {
                array.reserveCapacity(ProtoReader.collectionPreallocationSlotCount)
            }

            // This is a single entry in a regular repeated field
