-
Notifications
You must be signed in to change notification settings - Fork 464
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
WFCORE-6863 Add ServiceDescriptor convenience method for adding a requirement to a RuntimeCapability. #6046
Conversation
…uirement to a RuntimeCapability. Reduce heap requirements (by eliminating hash table allocation) for most use cases of addRequirements(...).
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
return this.addRequirements(requirements[0].getName(), requirements[1].getName()); | ||
default: | ||
Stream<String> mapped = Stream.of(requirements).map(NullaryServiceDescriptor::getName); | ||
this.requirements = (this.requirements.isEmpty() ? mapped : Stream.concat(this.requirements.stream(), mapped)).collect(Collectors.toUnmodifiableSet()); |
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.
if this.requirements.isEmpty()
is true, this.requirements
should be assigned to an unmodificable Set, however Stream<String> mapped
is not an unmodificable set at this point.
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.
Also, out of curiosity, why not use the code for the default: case always and remove the need for a switch? I mean, why use case 1 and 2?
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.
if this.requirements.isEmpty() is true, this.requirements should be assigned to an unmodificable Set, however Stream mapped is not an unmodificable set at this point.
I'm not sure what you mean. Both cases use the same collector that returns an unmodifiable 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.
Also, out of curiosity, why not use the code for the default: case always and remove the need for a switch? I mean, why use case 1 and 2?
Because we want to avoid allocating a hash table for only 1 or 2 entries, if possible.
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'm not sure what you mean. Both cases use the same collector that returns an unmodifiable set.
Forget it, I see it now, sorry for the noise about that.
return this.addRequirements(requirements[0].getName(), requirements[1].getName()); | ||
default: | ||
Stream<String> mapped = Stream.of(requirements).map(NullaryServiceDescriptor::getName); | ||
this.requirements = (this.requirements.isEmpty() ? mapped : Stream.concat(this.requirements.stream(), mapped)).collect(Collectors.toUnmodifiableSet()); |
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'm not sure what you mean. Both cases use the same collector that returns an unmodifiable set.
Forget it, I see it now, sorry for the noise about that.
Thanks @pferraro |
https://issues.redhat.com/browse/WFCORE-6863
Reduce heap requirements (by eliminating hash table allocation) for most use cases of addRequirements(...).