Improve performance when rendering diff lines.

This makes a number of optimizations to our diff rendering process:

1. Some unnecessary string comparisons from the diff_lines template tag
   have been simplified, so that we're only ever comparing one string.
   Small change, but one that should add up over the course of diffs.
   From performance testing, this appears to be roughly 30% faster
   overall.

2. We were checking if we needed to highlight regions for every
   single line, not just replace lines. This meant we did empty string
   checks, length checks, and string comparisons for every single line.
   These also added up, even though it only ever triggered the
   highlight region code for replace lines.

   Instead of all this work, we now check if it's a replace line
   up-front, preventing all the other checks.

3. Highlighting regions for a replace line is now twice as fast.
   Instead of parsing every character and keeping track of state,
   we're making use of `str.find`, which is much faster. We're also
   grabbing ranges of a string at a time, and reducing accesses to
   indexes of regions.