chaokunyang commented on code in PR #1701:
URL: https://github.com/apache/fury/pull/1701#discussion_r1670469747


##########
java/fury-core/src/main/java/org/apache/fury/serializer/collection/CollectionSerializer.java:
##########
@@ -45,6 +51,35 @@ public T onCollectionRead(Collection collection) {
     return (T) collection;
   }
 
+  @Override
+  public T copy(T originCollection) {
+    if (isImmutable()) {
+      return originCollection;
+    }
+    Collection newCollection;
+    if (!needToCopyRef) {
+      newCollection = newCollection(originCollection);
+      copyElements(originCollection, newCollection);
+      return (T) newCollection;
+    }
+    newCollection = (Collection) fury.getCopyObject(originCollection);
+    if (Objects.nonNull(newCollection)) {
+      return (T) newCollection;
+    }
+    fury.incCopyDepth(1);
+    newCollection = newCollection(originCollection);
+    fury.copyReference(originCollection, newCollection);

Review Comment:
   `copyReference` seems just track ref for copy, how about name it as 
`reference(T o1, T o2)`, it's an overload method, if we give it a detailed 
javadoc, it won't introduce confusion



-- 
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]

Reply via email to