Skip to content

Conversation

@copybara-service
Copy link

Change Utf8.encodedLength to just encode and check length.

This is a bit unfortunate: encoding conceptually does a lot more work (both computationally and an allocation) than simply determining how many bytes it should take to encode in Utf8 string. However, empirically the JDK/JVM has privilege which enables it to implement the getBytes() method faster than any other way to determine the length that we are able to write.

This is a bit unfortunate: encoding conceptually does a lot more work (both computationally and an allocation) than simply determining how many bytes it should take to encode in Utf8 string. However, empirically the JDK/JVM has privilege which enables it to implement the getBytes() method faster than any other way to determine the length that we are able to write.

PiperOrigin-RevId: 825109983
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.

2 participants