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

precompute hashCode for JavaClassType and SootClassMemberSignature #881

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

Liyw979
Copy link
Contributor

@Liyw979 Liyw979 commented Feb 28, 2024

This could look weird.
In my use case, I am using MethodSignature as key for caches like Map<MethodSignature, xxx> and found out that when doing code analysis, the cache is frequently read and about 15% of time is spent on hashCode().
Since MethodSignature and JavaClassType are immutable, the hashCode will not change so I cache them in this PR.

Copy link
Collaborator

@swissiety swissiety left a comment

Choose a reason for hiding this comment

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

👍 this seems very reasonable.
I think its not really necessary to do it on demand like its proposed in effective Java reference on Stackoverflow as we use those methods basically all the time as keys.

@swissiety swissiety merged commit 92c8285 into soot-oss:develop Feb 28, 2024
7 checks passed
@Liyw979 Liyw979 deleted the hashcode branch February 28, 2024 16:29
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.

2 participants