GEODE-2161: avoid unnecessary byte copy of hdos.

Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/44278d16
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/44278d16
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/44278d16

Branch: refs/heads/feature/GEODE-2156
Commit: 44278d165750d211a055d19e6e69ec21bb73edd9
Parents: fdd6166
Author: zhouxh <gz...@pivotal.io>
Authored: Thu Dec 1 10:18:15 2016 -0800
Committer: zhouxh <gz...@pivotal.io>
Committed: Thu Dec 1 16:15:15 2016 -0800

----------------------------------------------------------------------
 .../geode/internal/cache/FilterRoutingInfo.java     | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44278d16/geode-core/src/main/java/org/apache/geode/internal/cache/FilterRoutingInfo.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/FilterRoutingInfo.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/FilterRoutingInfo.java
index b3cf2e4..279a4d1 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/FilterRoutingInfo.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/FilterRoutingInfo.java
@@ -389,8 +389,12 @@ public class FilterRoutingInfo implements 
VersionedDataSerializable {
       }
       InternalDataSerializer.writeSetOfLongs(this.interestedClients, 
this.longIDs, hdos);
       InternalDataSerializer.writeSetOfLongs(this.interestedClientsInv, 
this.longIDs, hdos);
-      byte[] myData = hdos.toByteArray();
-      DataSerializer.writeByteArray(myData, out);
+      if (out instanceof HeapDataOutputStream) {
+        ((HeapDataOutputStream) out).writeAsSerializedByteArray(hdos);
+      } else {
+        byte[] myData = hdos.toByteArray();
+        DataSerializer.writeByteArray(myData, out);
+      }
     }
 
 
@@ -424,8 +428,12 @@ public class FilterRoutingInfo implements 
VersionedDataSerializable {
         }
         InternalDataSerializer.writeSetOfLongs(this.interestedClients, 
this.longIDs, hdos);
         InternalDataSerializer.writeSetOfLongs(this.interestedClientsInv, 
this.longIDs, hdos);
-        byte[] myData = hdos.toByteArray();
-        DataSerializer.writeByteArray(myData, out);
+        if (out instanceof HeapDataOutputStream) {
+          ((HeapDataOutputStream) out).writeAsSerializedByteArray(hdos);
+        } else {
+          byte[] myData = hdos.toByteArray();
+          DataSerializer.writeByteArray(myData, out);
+        }
       } else {
         DataSerializer.writeHashMap(this.cqs, out);
         InternalDataSerializer.writeSetOfLongs(this.interestedClients, 
this.longIDs, out);

Reply via email to