Convert all ~str to StrBuf
Shortcut to profile with valgrind.
Perf improvements.

Cleverly order the conditional testing so we avoid line
terminator checks (and peeking) in most cases.