update CharArrayUtil.fromSequence doc, use it instead of fromSequenceStrict

This commit is contained in:
peter
2013-11-24 19:03:43 +01:00
parent 85253bd2a2
commit bcd648e2e1
4 changed files with 12 additions and 10 deletions
@@ -19,7 +19,6 @@ import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.LocalTimeCounter;
import com.intellij.util.text.CharArrayCharSequence;
import com.intellij.util.text.CharArrayUtil;
@@ -468,7 +467,7 @@ abstract class CharArray implements CharSequenceBackedByArray, Dumpable {
try {
flushDeferredChanged();
if (myOriginalSequence != null && myArray == null) {
myArray = array = ArrayUtil.realloc(CharArrayUtil.fromSequence(myOriginalSequence), myOriginalSequence.length());
myArray = array = CharArrayUtil.fromSequence(myOriginalSequence);
myStringRef = null;
}
}
@@ -617,7 +617,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
@Override
@NotNull
public char[] textToCharArray() {
return CharArrayUtil.fromSequenceStrict(getViewProvider().getContents());
return CharArrayUtil.fromSequence(getViewProvider().getContents());
}
@NotNull
@@ -258,7 +258,7 @@ public abstract class LightPsiFileImpl extends PsiElementBase implements PsiFile
@Override
@NotNull
public char[] textToCharArray() {
return CharArrayUtil.fromSequenceStrict(getViewProvider().getContents());
return CharArrayUtil.fromSequence(getViewProvider().getContents());
}
@Override
@@ -99,13 +99,12 @@ public class CharArrayUtil {
}
}
/**
* @deprecated use {@link #fromSequence(CharSequence)}
*/
@NotNull
public static char[] fromSequenceStrict(@NotNull CharSequence seq) {
char[] chars = fromSequence(seq);
if (seq.length() == chars.length) return chars;
char[] strictChars = new char[seq.length()];
System.arraycopy(chars, 0, strictChars, 0, seq.length());
return strictChars;
return fromSequence(seq);
}
@Nullable
@@ -126,7 +125,6 @@ public class CharArrayUtil {
/**
* @return the underlying char[] array if any, or the new chara array if not
* NOTE RETURNED ARRAY LENGTH MAY HAVE BE DIFFERENT FROM THE seq.length()
*/
@NotNull
public static char[] fromSequence(@NotNull CharSequence seq) {
@@ -155,6 +153,11 @@ public class CharArrayUtil {
((StringBuffer)seq).getChars(0, seq.length(), chars, 0);
return chars;
}
if (seq instanceof StringBuilder) {
char[] chars = new char[seq.length()];
((StringBuilder)seq).getChars(0, seq.length(), chars, 0);
return chars;
}
if (seq instanceof String) {
char[] chars = new char[seq.length()];