=rem #16428 optimize protobuf serializer for master

#16428 for master
Too much duplication for my taste, especially since it can be avoided easily ;)