SIGN IN SIGN UP

Protocol Buffers - Google's data interchange format

0 0 34 C++

Optimize ExtensionSet::MergeFrom for flat map.

Avoids a double iteration over the source ExtensionSet when merging into an empty flat map ExtensionSet. The flat array is now allocated on demand within the merge loop, and the size is adjusted for cleared extensions at the beginning.

Notes:
1. If all extensions cleared, no memory will be allocated.
2. Cleared extentions that are at the beginning would be "fully removed". No memory for them will be allocated.
3. Other cleared may get memory allocated. But we will return unnecessary memory in case of overallocation.
PiperOrigin-RevId: 897615380
V
Vitaly Goldshteyn committed
48ce31daef690ea584a6d7e0e9bc34928013f2e2
Parent: 396717a
Committed by Copybara-Service <copybara-worker@google.com> on 4/10/2026, 11:25:50 AM