Optimized String#each_char.

Fixes #2911.
Related to #2907.

See full commit messages for further explanation.