=rem #16428 optimize protobuf serializer for master

#16428 for master
I think @viktorklang 's way is more elegant and @rkuhn & @patriknw 's way is more easier to understand,the fact is that this piece is not apart of the public API ,so