Use a fast path when initializing LineOffsetMapping
authorserge-sans-paille <sguelton@redhat.com>
Tue, 23 Feb 2021 19:46:35 +0000 (20:46 +0100)
committerserge-sans-paille <sguelton@redhat.com>
Mon, 1 Mar 2021 09:18:36 +0000 (10:18 +0100)
commit80e8efd563fda4d7b125b834d3243b3ef9a05270
treedbf251ea2631ce3173a82ddbf832d86e3925b57d
parent588db1ccff713332c1f9358f423e682f18c06e8e
Use a fast path when initializing LineOffsetMapping

Use the fact that the number of line break is lower than printable characters to
guide the optimization process. Also use a fuzzy test that catches both \n and
\r in a single check to speedup the computation.

Differential Revision: https://reviews.llvm.org/D97320
clang/lib/Basic/SourceManager.cpp