mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
update CharArrayUtil.fromSequence doc, use it instead of fromSequenceStrict
This commit is contained in:
@@ -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()];
|
||||
|
||||
Reference in New Issue
Block a user