SIGN IN SIGN UP

Protocol Buffers - Google's data interchange format

0 0 50 C++

Avoid always parsing all lazy extensions on equals()

Today, equals() causes all lazy extensions to be parsed before the equality check starts. After this change, equals() will try to avoid hitting lazy parsing if possible

Notably:
- When the count of extensions don't match, or if "which extensions are set" don't match, we can return false before looking at any extension values.

- When actually comparing extensions, it goes iteratively which means it'll only parse the extensions as it goes; if it finds any one ext which is not-equal it will will bail out and not parse any of the rest.

Note that when the case where two messages are equal, this unavoidably still cause all extensions to parse since it has to examine all fields.

To achieve this does require adding a protected `extensionsEquals()` method for the gencode to call, since the current base class API isn't otherwise powerful enough to do so.

PiperOrigin-RevId: 924903438
P
Protobuf Team Bot committed
64d0bca8af7e0bfa23c60b31e34f6bf9af0e10f1
Parent: 524871b
Committed by Copybara-Service <copybara-worker@google.com> on 6/1/2026, 9:12:34 PM