Skip to content

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Oct 17, 2025

Change BoundedByteString to not subclass LiteralByteString and make LiteralByteString final.

The majority of ByteStrings are LiteralByteStrings (and not Bounded ones) in practice since that is what a parse of unknown fields, bytes fields, and string fields with utf-validation-none will construct. This change avoids confusion and keeps the the hottest path as clean and simple as possible.

This makes LiteralByteString.equals(LiteralByteString) as clean/hot as possible by using Arrays.equals(), and still maintains a hot path for cases where LiteralByteStrings <> BoundedByteStrings are mutually compared.

As these types are all implementation details, we can safely reshape the inheritance structure.

This diff looks a bit larger than it really is; most of the lines added are simply the fork of the 1-line methods and the diff tool is not smart enough to realize that.

@copybara-service copybara-service bot force-pushed the test_820273934 branch 2 times, most recently from 6a9215c to 440822d Compare October 17, 2025 18:24
…iteralByteString final.

The majority of ByteStrings are LiteralByteStrings (and not Bounded ones) in practice since that is what a parse of unknown fields, bytes fields, and string fields with utf-validation-none will construct. This change avoids confusion and keeps the the hottest path as clean and simple as possible.

This makes `LiteralByteString.equals(LiteralByteString)` as clean/hot as possible by using Arrays.equals(), and still maintains a hot path for cases where LiteralByteStrings <> BoundedByteStrings are mutually compared.

As these types are all implementation details, we can safely reshape the inheritance structure.

This diff looks a bit larger than it really is; most of the lines added are simply the fork of the 1-line methods and the diff tool is not smart enough to realize that.

PiperOrigin-RevId: 820273934
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant