Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved performance of annotateUtil. #2465

Merged
merged 2 commits into from Apr 30, 2022
Merged

Improved performance of annotateUtil. #2465

merged 2 commits into from Apr 30, 2022

Conversation

k163377
Copy link
Contributor

@k163377 k163377 commented Apr 29, 2022

I am not good at English, so I apologize if I am rude.

Summary of Changes

Changed annotateUtil function to not use Local function.

Rationale for Performance Improvement

Decompile the current getBracketLevel function to Java as follows

   public final void annotateUtil(/* */) {
      <undefinedtype> $fun$getBracketLevel$1 = new Function1() {
         public final int invoke(@NotNull LeafPsiElement element) {
            <undefinedtype> $fun$iterateParents$1 = new Function1() {
               public final void invoke(@NotNull final PsiElement currentNode) {
                  while(true) {
                     <undefinedtype> $fun$iterateChildren$1 = new Function1() {
                        public final void invoke(@NotNull PsiElement currentChild) {
                        }
                     };
                  }
               }
            };
         };
      };
   }

From this result, we can read that the getBracketLevel and iterateParents functions are instantiated at each call to annotateUtil, and that the iterateChildren function is instantiated at each loop of iterateParents.
Modifying to not use Local function would improve performance by eliminating these instantiation costs.

@izhangzhihao
Copy link
Owner

great catch!I will test on this later, thanks for your contribution!

Copy link
Owner

@izhangzhihao izhangzhihao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works great, and the bytecode looks much better!

@izhangzhihao izhangzhihao merged commit ffc4d92 into izhangzhihao:2020.3 Apr 30, 2022
@k163377 k163377 deleted the refactor-rainbow_annotator branch April 30, 2022 03:32
@online5880
Copy link

This does not apply to the rider for unreal engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants