yhs0092 commented on code in PR #4747:
URL:
https://github.com/apache/servicecomb-java-chassis/pull/4747#discussion_r2077029869
##########
foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceVersions.java:
##########
@@ -148,6 +148,10 @@ public List<MicroserviceInstance> getPulledInstances() {
return pulledInstances;
}
+ public List<MicroserviceInstance> getInstances() {
+ return new ArrayList<MicroserviceInstance>(instances);
Review Comment:
I know this method is originally designed for internal low-frequency usage,
but It may be used by users in the future, so the performance of this method
can be take into consideration in advance. This method may be costly when there
are many provider instances. Is it necessary to create a copy for each time of
method invocation?
For the better performance, I guess there are two alternatives:
1. just return `this.instances`, the invokers should gurantee their usage
should not impact the inner state of this Object.
2. return a read-only view by wrapping instances with
`Collections.unmodifiableCollection`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]