[all-commits] [llvm/llvm-project] d604c5: [NFC] Use find_last_of when seraching for code in ...
Kugan via All-commits
all-commits at lists.llvm.org
Tue Feb 21 08:26:06 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d604c57164ecdb3084c8d00f9575158fddc30f81
https://github.com/llvm/llvm-project/commit/d604c57164ecdb3084c8d00f9575158fddc30f81
Author: Kugan Vivekanandarajah <kuganv at gmail.com>
Date: 2023-02-21 (Tue, 21 Feb 2023)
Changed paths:
M clang/lib/AST/ASTContext.cpp
Log Message:
-----------
[NFC] Use find_last_of when seraching for code in getRawCommentForDeclNoCacheImpl
ASTContext::getRawCommentForDeclNoCacheImpl in this case, extracts the text between
the comment and declaration to make sure if there are no other declarations or preprocessor
directives between comment or declarations.
While using Text.find_first_of or Text.find_last_of is functionally the same,
using Text.find_last_of terminates fast in the presence of such.
Especially in generated code with sparse comments, it takes longer
to bailout when there is code in-between. Searching from last
(with find_last_of) bails out faster.
This shows up in perf profiles with clangd in some auto-generated code.
ASTContext::getRawCommentForDeclNoCacheImpl showing as much as 18.2% in this
case. With find_last_of, this drops to 2.8%.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D141950
More information about the All-commits
mailing list