[PATCH] Add CRLF support to LineIterator.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Sun Nov 2 17:08:31 PST 2014


On 1 November 2014 21:55, Chandler Carruth <chandlerc at gmail.com> wrote:
> So, I'm OK with this... but I wonder what it does to the performance of the line iterator. Hopefully we never care.

If someone does I am happy with trying to write an explicit state
machine for it, I just went with the simplest solution under the
assumption that no one cared.

> I've made a minor suggestion below that should at least make one of the cases quite a bit simpler.
>
> ================
> Comment at: lib/Support/LineIterator.cpp:64-65
> @@ -44,6 +63,4 @@
>      // If we're not stripping comments, this is simpler.
> -    size_t Blanks = 0;
> -    while (Pos[Blanks] == '\n')
> -      ++Blanks;
> -    Pos += Blanks;
> -    LineNumber += Blanks;
> +    while (isAtLineEnd(Pos)) {
> +      skipLineEnd(Pos);
> +      ++LineNumber;
> ----------------
> This suggests that skipLineEnd should return whether it did indeed skip a line end?

Good point. I will attach a new patch.



More information about the llvm-commits mailing list