buffer: don't call ByteLength for simple encodings

For several encodings the byte length is simple arithmetic. Don't call
into C++ in those cases.