returns unmodifiable sets - #1071
Conversation
…ames and available animation clips instead of an unmodifiable collection. fixes: #1070
|
These changes create a LOT of garbage. The animation names one does so unnecessarily since it was already a set. No need to create a new one just to again wrap it in an unmodifiable wrapper. I'm kind of against the clips -> Set change just because the data doesn't support it. There is no good reason to return Set here when a documentation change would do and not have as much garbage. |
|
I agree with you concerning the animation names, I did wrap them in an UnmodifiableSet to keep in line with the current implementation but I indeed used an unnecessary wrapper set. Just need to be careful that the returned object is wrapped in a new object (be it collection or set) so the underlying map isn't modified. For the Collection vs Set discussion, I don't really have a strong opinion. But a Set makes senses imo. |
|
For AnimClip objects, a set would make sense if it were already a set. But it isn't. Set is "nice to have" because it auto-documents. That's it. In this case, the same can be achieved by mentioning something in the javadoc... though I guess no one will ever really care because the names are already a set. Also, while today's implementation may be one-to-one mapping between name and AnimClip instance, that is not a requirement of this part of the API and I think it's a mistake to reflect it here for "no good reason". |
|
If it's not possible to convert |
|
I concur with avove remarks. Is this an ok solution? |
|
ok |
|
@stephengold wasn't getAnimClips supposed to reverted back to return Collection ? |
|
Yep... this wasn't ready to apply yet, unfortunately. Still has the crappy duplication of hashset every time getAnimClips() is called... for no good reason other than "let's return a set"... which itself is also not a good reason. |
|
I was/am on a short holiday during the easter weekend with no access to my pc. I'll create a new PR this evening with the discussed changes in it. |
This reverts commit ffa1df2.
|
Oops! My bad. |
Returns an unmodifiable set when retrieving the available animation names and available animation clips instead of an unmodifiable collection. fixes: #1070