fixed performance of DataNode#hashCode
authorFedor Korotkov <fedor.korotkov@gmail.com>
Thu, 3 Sep 2015 07:39:28 +0000 (10:39 +0300)
committernik <Nikolay.Chashnikov@jetbrains.com>
Thu, 3 Sep 2015 07:40:08 +0000 (10:40 +0300)
platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java

index 86e35d1d5aa4095883abed6bc223f3a09ea02437..3e89fd8febfb0181107eee067ffbdb8eaf6cb902 100644 (file)
@@ -22,7 +22,6 @@ import com.intellij.openapi.util.io.StreamUtil;
 import com.intellij.util.containers.ContainerUtilRt;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.TestOnly;
 
 import java.io.*;
 import java.lang.reflect.Modifier;
@@ -279,10 +278,9 @@ public class DataNode<T> implements Serializable, UserDataHolderEx {
 
   @Override
   public int hashCode() {
-    int result = myChildren.hashCode();
-    result = 31 * result + myKey.hashCode();
-    result = 31 * result + getData().hashCode();
-    return result;
+    // We can't use myChildren.hashCode() because it iterates whole subtree. This should not produce many collisions because 'getData()'
+    // usually refers to different objects
+    return 31 * myKey.hashCode() + getData().hashCode();
   }
 
   @Override