mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not create strings just to create (String)Reader when we can use CharArrayReader (quite often we can get char[] form sequence)
This commit is contained in:
@@ -19,9 +19,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.*;
|
||||
import java.nio.CharBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -547,4 +545,12 @@ public class CharArrayUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Reader readerFromCharSequence(CharSequence text) {
|
||||
Reader reader;
|
||||
char[] chars = fromSequenceWithoutCopying(text);
|
||||
if (chars != null) reader = new CharArrayReader(chars, 0, text.length());
|
||||
else reader = new StringReader(text.toString());
|
||||
return reader;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.indexing.*;
|
||||
import com.intellij.util.io.EnumeratorIntegerDescriptor;
|
||||
import com.intellij.util.io.KeyDescriptor;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.xml.NanoXmlUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -41,8 +41,8 @@ public class AntImportsIndex extends ScalarIndexExtension<Integer>{
|
||||
@NotNull
|
||||
public Map<Integer, Void> map(final FileContent inputData) {
|
||||
final Map<Integer, Void> map = new HashMap<Integer, Void>();
|
||||
|
||||
NanoXmlUtil.parse(new StringReader(inputData.getContentAsText().toString()), new NanoXmlUtil.IXMLBuilderAdapter() {
|
||||
|
||||
NanoXmlUtil.parse(CharArrayUtil.readerFromCharSequence(inputData.getContentAsText()), new NanoXmlUtil.IXMLBuilderAdapter() {
|
||||
private boolean isFirstElement = true;
|
||||
@Override
|
||||
public void startElement(final String elemName, final String nsPrefix, final String nsURI, final String systemID, final int lineNr) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user