Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid boxing when serializing primitive lists in CodedOutputStreamWriter
Previously, these List.get methods returned Object, forcing boxing, and (if not in the primitive's box cache) allocation, with all the cost that entails. I've taken the approach of duplicating methods to specialise for primitives, like BinaryWriter does for non-lite protos. I initially considered checking the class of the list on every iteration of the loop, but that feels wasteful, when we can check it once at the start of the loop. This also means we have the same behaviour as serverside protos. At the cost of a few more methods, but hopefully they're trivially inlineable, so hopefully leading to a small dex increase without really increasing the method count. Given this is a public API, I don't think we can remove the List<Long> overloads either. PiperOrigin-RevId: 627183583
- Loading branch information