Optimize html conversion to escaped UTF-16 JS
Optimize html conversion to escaped UTF-16 JS

Don't constantly check if reading multi-byte UTF-8 encoded codepoints
will read beyond the end of the string. Instead process the string till
size - 4 (4 being the most bytes that could be read in one go) without
any checking, and then ensure there is no overflow at the last few
bytes.

Don't constantly check if appending to buffer will cause it to overflow,
instead calculate the maximum of bytes that could be processed without
overflow and process them without checks. Expand buffer when it is low
in remaining space.

JaySandhu/vimdown,JaySandhu/vimdown,JaySandhu/vimdown