add EncodedSize that calculates the encoded size more efficiently. (#245)

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
9 jobs for master in 22 minutes and 18 seconds (queued for 3 seconds)