[cfe-commits] [PATCH] Optimize SourceManager::getColumnNumber to fix PR14106

Craig Topper craig.topper at gmail.com
Thu Oct 18 10:02:05 PDT 2012


Sure, I can make that change. After that is it ok to commit?

On Thu, Oct 18, 2012 at 9:43 AM, Douglas Gregor <dgregor at apple.com> wrote:

> On Oct 17, 2012, at 6:04 PM, Craig Topper <craig.topper at gmail.com> wrote:
>
> > This patch uses the line number cache to find the start of the line
> instead of searching backwards for it. This helps performance in cases
> where the line is long and have just called getLineNumber for the same
> position.
>
> This only helps when the FilePos is exactly the same as the FilePos that
> went to getLineNumber:
>
> +  // See if we just calculated the line number for this FilePos and can
> use
> +  // that to lookup the start of the line instead of searching for it.
> +  if (LastLineNoFileIDQuery == FID && LastLineNoFilePos == (FilePos + 1))
> {
>
> Why not simply check that FilePos > SourceLineCache[LastLineNoResult - 1]
> and < SourceLineCache[LastLineNoResult], so anything on the
> most-recently-queried line can be handled efficiently?
>
>         - Doug
>
>


-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121018/2ebb1c0a/attachment.html>


More information about the cfe-commits mailing list