Skip to content

precompute hashCode for JavaClassType and SootClassMemberSignature#881

Merged
swissiety merged 1 commit intosoot-oss:developfrom
Liyw979:hashcode
Feb 28, 2024
Merged

precompute hashCode for JavaClassType and SootClassMemberSignature#881
swissiety merged 1 commit intosoot-oss:developfrom
Liyw979:hashcode

Conversation

@Liyw979
Copy link
Copy Markdown
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
Copy Markdown
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
@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