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


##########
java/fury-core/src/main/java/org/apache/fury/serializer/ArraySerializers.java:
##########
@@ -85,52 +103,69 @@ public void write(MemoryBuffer buffer, T[] arr) {
       int len = arr.length;
       RefResolver refResolver = fury.getRefResolver();
       Serializer componentSerializer = this.componentTypeSerializer;
-      int header = componentSerializer != null ? 0b1 : 0b0;
-      buffer.writeVarUint32Small7(len << 1 | header);
-      if (componentSerializer != null) {
-        for (T t : arr) {
-          if (!refResolver.writeRefOrNull(buffer, t)) {
-            componentSerializer.write(buffer, t);
-          }
-        }
+      if (this.collectionSerializer != null) {
+        fury.getGenerics().pushGenericType(this.collectionGenericType);
+        ArrayAsList list = new ArrayAsList(0);

Review Comment:
   Could we cache this object as a field.  Nested serialization is a rare case, 
if we cache it as a field, we could save object creation cost. 
   
   We could write like :
   ```java
   ArrayAsList list = this.list;
   if (list == null) {
     list = new ArrayAsList(0);
   } else {
     this.list = null
   }
   
   // before serialiazation
   
   ...
   
   
   // after serialization
   
   this.list = list
   
   ```



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