inline always same value field
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Wed, 12 Aug 2020 07:28:32 +0000 (10:28 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Wed, 12 Aug 2020 11:40:33 +0000 (11:40 +0000)
GitOrigin-RevId: cf4971314836f0aae91acecaea0f81b280a12f33

platform/indexing-impl/src/com/intellij/psi/stubs/PrebuiltStubs.kt
platform/indexing-impl/src/com/intellij/psi/stubs/SerializedStubTreeDataExternalizer.java
platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java

index 09197ba175462ae1bbaee9de0dc6ff1f1282133a..f1e3b76932dabda020d04ded845a0572ac25a28d 100644 (file)
@@ -63,8 +63,7 @@ open class HashCodeExternalizers : DataExternalizer<HashCode> {
   }
 }
 
-class GeneratingFullStubExternalizer : SerializedStubTreeDataExternalizer(true,
-                                                                          SerializationManagerEx.getInstanceEx(),
+class GeneratingFullStubExternalizer : SerializedStubTreeDataExternalizer(SerializationManagerEx.getInstanceEx(),
                                                                           StubForwardIndexExternalizer.createFileLocalExternalizer())
 
 abstract class PrebuiltStubsProviderBase : PrebuiltIndexProvider<SerializedStubTree>(), PrebuiltStubsProvider {
@@ -74,7 +73,7 @@ abstract class PrebuiltStubsProviderBase : PrebuiltIndexProvider<SerializedStubT
 
   override val indexName: String get() = SDK_STUBS_STORAGE_NAME
 
-  override val indexExternalizer: SerializedStubTreeDataExternalizer get() = SerializedStubTreeDataExternalizer(true, mySerializationManager, StubForwardIndexExternalizer.createFileLocalExternalizer())
+  override val indexExternalizer: SerializedStubTreeDataExternalizer get() = SerializedStubTreeDataExternalizer(mySerializationManager, StubForwardIndexExternalizer.createFileLocalExternalizer())
 
   companion object {
     const val PREBUILT_INDICES_PATH_PROPERTY = "prebuilt_indices_path"
index 5bf4f3f0d5f80a04e1932dcaab410d9579dfba30..ecceb34943816c4660d9773f9bff7881aba9b7c8 100644 (file)
@@ -1,7 +1,6 @@
 // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 package com.intellij.psi.stubs;
 
-import com.intellij.util.ArrayUtil;
 import com.intellij.util.CompressionUtil;
 import com.intellij.util.io.DataExternalizer;
 import com.intellij.util.io.DataInputOutputUtil;
@@ -13,13 +12,11 @@ import java.io.DataOutput;
 import java.io.IOException;
 
 public class SerializedStubTreeDataExternalizer implements DataExternalizer<SerializedStubTree> {
-  private final boolean myIncludeInputs;
   @NotNull
   private final SerializationManagerEx mySerializationManager;
   private final StubForwardIndexExternalizer<?> myStubIndexesExternalizer;
 
-  public SerializedStubTreeDataExternalizer(boolean inputs, @NotNull SerializationManagerEx manager, @NotNull StubForwardIndexExternalizer<?> externalizer) {
-    myIncludeInputs = inputs;
+  public SerializedStubTreeDataExternalizer(@NotNull SerializationManagerEx manager, @NotNull StubForwardIndexExternalizer<?> externalizer) {
     mySerializationManager = manager;
     myStubIndexesExternalizer = externalizer;
   }
@@ -29,14 +26,12 @@ public class SerializedStubTreeDataExternalizer implements DataExternalizer<Seri
     if (PersistentHashMapValueStorage.COMPRESSION_ENABLED) {
       DataInputOutputUtil.writeINT(out, tree.myTreeByteLength);
       out.write(tree.myTreeBytes, 0, tree.myTreeByteLength);
-      if (myIncludeInputs) {
-        DataInputOutputUtil.writeINT(out, tree.myIndexedStubByteLength);
-        out.write(tree.myIndexedStubBytes, 0, tree.myIndexedStubByteLength);
-      }
+      DataInputOutputUtil.writeINT(out, tree.myIndexedStubByteLength);
+      out.write(tree.myIndexedStubBytes, 0, tree.myIndexedStubByteLength);
     }
     else {
       CompressionUtil.writeCompressed(out, tree.myTreeBytes, 0, tree.myTreeByteLength);
-      if (myIncludeInputs) CompressionUtil.writeCompressed(out, tree.myIndexedStubBytes, 0, tree.myIndexedStubByteLength);
+      CompressionUtil.writeCompressed(out, tree.myIndexedStubBytes, 0, tree.myIndexedStubByteLength);
     }
   }
 
@@ -49,20 +44,15 @@ public class SerializedStubTreeDataExternalizer implements DataExternalizer<Seri
       in.readFully(bytes);
       int indexedStubByteLength;
       byte[] indexedStubBytes;
-      if (myIncludeInputs) {
-        indexedStubByteLength = DataInputOutputUtil.readINT(in);
-        indexedStubBytes = new byte[indexedStubByteLength];
-        in.readFully(indexedStubBytes);
-      } else {
-        indexedStubByteLength = 0;
-        indexedStubBytes = ArrayUtil.EMPTY_BYTE_ARRAY;
-      }
+      indexedStubByteLength = DataInputOutputUtil.readINT(in);
+      indexedStubBytes = new byte[indexedStubByteLength];
+      in.readFully(indexedStubBytes);
       return new SerializedStubTree(bytes, bytes.length, indexedStubBytes, indexedStubByteLength,
                                     null, myStubIndexesExternalizer, mySerializationManager);
     }
     else {
       byte[] treeBytes = CompressionUtil.readCompressed(in);
-      byte[] indexedStubBytes = myIncludeInputs ? CompressionUtil.readCompressed(in) : ArrayUtil.EMPTY_BYTE_ARRAY;
+      byte[] indexedStubBytes = CompressionUtil.readCompressed(in);
       return new SerializedStubTree(treeBytes, treeBytes.length, indexedStubBytes, indexedStubBytes.length,
                                     null, myStubIndexesExternalizer, mySerializationManager);
     }
index 7030065f22be89ba47dab1349b8b4df69ce38270..e97c854881c032555fd3178bbf4ad4df7f7439bb 100644 (file)
@@ -304,7 +304,7 @@ public final class StubUpdatingIndex extends SingleEntryFileBasedIndexExtension<
   @Override
   public DataExternalizer<SerializedStubTree> getValueExternalizer() {
     ensureSerializationManagerInitialized(mySerializationManager);
-    return new SerializedStubTreeDataExternalizer(true, mySerializationManager, myStubIndexesExternalizer);
+    return new SerializedStubTreeDataExternalizer(mySerializationManager, myStubIndexesExternalizer);
   }
 
   @NotNull