While profiling InclusionRewriter, it was found that counting lines was
so slow that it took up 20% of the processing time. Surely, calling
memcmp() of size 1 on every substring in the window isn't a good idea.
Use StringRef::find() instead; in the case of N=1 it will forward to
memcmp which is much more optimal. For 2<=N<256 it will run the same
memcmp loop as we have now, which is still suboptimal but at least does
not regress anything.
The !N condition needs to be retained, otherwise we will go into an infinite loop for an empty Str. I believe this causes the ADTTest timeout.
(Returning 0 for an empty string isn't really right, this should return Length + 1, but this is orthogonal to your change.)