Faster implementation of `ScalaCommentScanner`

Hopefully an imperative loop is fast enough, otherwise I have to think
about a different algorithm.

Fixes #1002241