less garbage and synchronization during building indexed
authorMaxim.Mossienko <maxim.mossienko@jetbrains.com>
Fri, 27 Jan 2012 13:58:48 +0000 (17:58 +0400)
committerMaxim.Mossienko <maxim.mossienko@jetbrains.com>
Fri, 27 Jan 2012 15:24:07 +0000 (19:24 +0400)
platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java
platform/util/src/com/intellij/util/lang/JarMemoryLoader.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltSymbolIndex.java

index 3ab8d0060740e8c00f7973d24e18cb74aa7ec4ee..eb8ba08a3140b84e9749f924c121e02461eb8ebf 100644 (file)
@@ -25,8 +25,8 @@ import com.intellij.openapi.util.io.StreamUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.ConcurrentHashMap;
 import com.intellij.util.io.PagePool;
+import com.intellij.util.io.UnsyncByteArrayInputStream;
 
-import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.util.Map;
@@ -58,7 +58,7 @@ public class RefCountingStorage extends AbstractStorage {
     synchronized (myLock) {
 
       byte[] result = super.readBytes(record);
-      InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(result));
+      InflaterInputStream in = new InflaterInputStream(new UnsyncByteArrayInputStream(result));
       try {
         return StreamUtil.loadFromStream(in);
       }
index 63f9a81171a46b6c5b3bc5de47059d72ccd997ba..44628c743e826691160fddab1fcd892d3181ea6b 100644 (file)
@@ -1,6 +1,7 @@
 package com.intellij.util.lang;
 
 import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.util.io.UnsyncByteArrayInputStream;
 import com.intellij.util.io.zip.ZipShort;
 import gnu.trove.THashMap;
 import org.jetbrains.annotations.Nullable;
@@ -95,7 +96,7 @@ public class JarMemoryLoader {
 
     @Override
     public InputStream getInputStream() throws IOException {
-      return new ByteArrayInputStream(myContent);
+      return new UnsyncByteArrayInputStream(myContent);
     }
 
     @Override
index 05810b698f1d01c04af4b699dc336fbed4e6bcd6..cfb60158ed04d8d2c17b0dd700b20d8cc08da564 100644 (file)
@@ -29,10 +29,7 @@ import com.intellij.psi.xml.XmlFile;
 import com.intellij.psi.xml.XmlTag;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.indexing.*;
-import com.intellij.util.io.DataExternalizer;
-import com.intellij.util.io.EnumDataDescriptor;
-import com.intellij.util.io.EnumeratorStringDescriptor;
-import com.intellij.util.io.KeyDescriptor;
+import com.intellij.util.io.*;
 import com.intellij.util.text.CharArrayUtil;
 import com.intellij.util.xml.NanoXmlUtil;
 import org.intellij.lang.xpath.xslt.XsltSupport;
@@ -41,7 +38,6 @@ import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import java.io.ByteArrayInputStream;
 import java.util.*;
 
 /*
@@ -94,7 +90,7 @@ public class XsltSymbolIndex extends FileBasedIndexExtension<String, XsltSymbolI
                   return Collections.emptyMap();
                 }
                 final HashMap<String, Kind> map = new HashMap<String, Kind>();
-                NanoXmlUtil.parse(new ByteArrayInputStream(inputData.getContent()), new NanoXmlUtil.IXMLBuilderAdapter() {
+                NanoXmlUtil.parse(new UnsyncByteArrayInputStream(inputData.getContent()), new NanoXmlUtil.IXMLBuilderAdapter() {
                     NanoXmlUtil.IXMLBuilderAdapter attributeHandler;
                     int depth;