chaokunyang commented on code in PR #2999:
URL: https://github.com/apache/fory/pull/2999#discussion_r2591274707
##########
java/fory-core/src/main/java/org/apache/fory/serializer/collection/CollectionSerializers.java:
##########
@@ -294,6 +295,27 @@ public CopyOnWriteArrayList onCollectionRead(Collection
collection) {
}
}
+ public static class CopyOnWriteArraySetSerializer
+ extends ConcurrentCollectionSerializer<CopyOnWriteArraySet> {
+
+ public CopyOnWriteArraySetSerializer(Fory fory, Class<CopyOnWriteArraySet>
type) {
+ super(fory, type, true);
+ }
+
+ @Override
+ public Collection newCollection(MemoryBuffer buffer) {
+ int numElements = buffer.readVarUint32Small7();
+ setNumElements(numElements);
+ return new CollectionContainer<>(numElements);
+ }
+
+ @Override
+ public CopyOnWriteArraySet onCollectionRead(Collection collection) {
Review Comment:
This is what I am worried, you will copy `CopyOnWriteArraySet` every time
you put an element into the Set when copying.
You should overide copy method to avoid such cost. It seems copy for other
collections can be optimized too.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]