Make Rewriter a total function (AnyRef => AnyRef) rather than (AnyRef => Option[AnyRef])

In practice, some combinators already made assumptions about it being the case.
There doesn't seem to be a benefit for the partiality other than a short-circuit in repeat().
However, we rely on identity equality to be roughly as performant as a runtime check
for whether Option[AnyRef] is Some(_) or None.
Various optimisations in planning of hot spots found when profiling
Merge pull request #3270 from pontusmelke/profiling-changes

[2.2] Change Rewriter to be a total function