=rem #16428 optimize protobuf serializer for master

#16428 for master
Ah, and one more thought: the declaration of the local methods does not need to be nested as far as I can see. Is it possible that this discussion has drilled itself into some rabbit hole?