The first version of the Editor did look a lot like a peephole optimizer, but modern compilers are often written in a "broad" fashion, where (with the benefit of lots of resources like memory) they make multiple passes over the code, with each pass focusing on one particular transformation. The Editor could really use the same approach, since efficiency is not really an issue, and the current code is really pretty confusing, as it tries to make several transformations in a single pass.
The first version of the Editor did look a lot like a peephole optimizer, but modern compilers are often written in a "broad" fashion, where (with the benefit of lots of resources like memory) they make multiple passes over the code, with each pass focusing on one particular transformation. The Editor could really use the same approach, since efficiency is not really an issue, and the current code is really pretty confusing, as it tries to make several transformations in a single pass.