Small optimization for scanner functions

Discovered while fixing bug 726108.