more tiny improvements

* use `charAt` insteadof `startsWith`/`endsWith` when checking for single characters
* reduce number of times a `String`'s backing `char[]` is copied