[all-commits] [llvm/llvm-project] a6a0d9: [SourceManager] Improve getFileIDLocal.

Haojian Wu via All-commits all-commits at lists.llvm.org
Fri Oct 7 00:37:24 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a6a0d9ecd5d744316e699fa78a053376bb659dd1
      https://github.com/llvm/llvm-project/commit/a6a0d9ecd5d744316e699fa78a053376bb659dd1
  Author: Haojian Wu <hokein.wu at gmail.com>
  Date:   2022-10-07 (Fri, 07 Oct 2022)

  Changed paths:
    M clang/lib/Basic/SourceManager.cpp

  Log Message:
  -----------
  [SourceManager] Improve getFileIDLocal.

Prune the search space -- If we know offset(LastFileIDLookup) < SearchOffset, we
can prune the initial binary-search range from [0, end) to [LastFileIDlookup, end).

It reduces the binary search scan by ~30%.

SemaExpr.cpp:   1393437 -> 1035426
FindTarget.cpp: 1275930 -> 920087

Linux kernel:
getFileIDLocal: 2.45% -> 2.15%

Differential Revision: https://reviews.llvm.org/D135132




More information about the All-commits mailing list