-
Notifications
You must be signed in to change notification settings - Fork 413
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
OAK-11360: remove usage of Guava Ints.contains() #1958
Conversation
Commit-Check ✔️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
|
||
public static boolean canCreateTypedField(Type<?> type) { | ||
return Ints.contains(TYPABLE_TAGS, type.tag()); | ||
return TYPABLE_TAGS.contains(type.tag()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return TYPABLE_TAGS.contains(type.tag()); | |
return Arrays.stream(TYPABLE_TAGS).anyMatch(tag -> tag == type.tag()); |
and we keep the type of TYPABLE_TAGS
as int[]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we could change TYPABLE_TAGS
to Set
and take advantage of Set.contains
API.
@reschke wdyt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to avoid to convert ints to Integers every time we do the check.
I also assumed that the original author believed that sorting the array/list would help improve performance.
If this is not the case we of course could make it a Set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK List.contains
always run in linear time irrespective of whether List
is sorted or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorting only helps if the lower values need to be looked up more frequently.
We could check the code what is really needed here. Or we can just keep things the way they are :-)
Quality Gate passedIssues Measures |
No description provided.