Skip to content
Commit d604c571 authored by Kugan Vivekanandarajah's avatar Kugan Vivekanandarajah Committed by Ivan Murashko
Browse files

[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
parent 1b634c0d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment