[armedbear-cvs] r12494 - trunk/abcl/src/org/armedbear/lisp
Ville Voutilainen
vvoutilainen at common-lisp.net
Sun Feb 21 14:33:14 UTC 2010
Author: vvoutilainen
Date: Sun Feb 21 09:33:12 2010
New Revision: 12494
Log:
Don't use StringBuilder for StringFunctions that can use arraycopy
instead. This requires making the relevant SimpleString constructor
public.
Modified:
trunk/abcl/src/org/armedbear/lisp/SimpleString.java
trunk/abcl/src/org/armedbear/lisp/StringFunctions.java
Modified: trunk/abcl/src/org/armedbear/lisp/SimpleString.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SimpleString.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/SimpleString.java Sun Feb 21 09:33:12 2010
@@ -78,7 +78,7 @@
capacity = chars.length;
}
- private SimpleString(char[] chars)
+ public SimpleString(char[] chars)
{
this.chars = chars;
capacity = chars.length;
Modified: trunk/abcl/src/org/armedbear/lisp/StringFunctions.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/StringFunctions.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/StringFunctions.java Sun Feb 21 09:33:12 2010
@@ -555,16 +555,17 @@
{
StringIndicesAndChars indicesAndChars =
stringIndicesAndChars(first, second, third);
- StringBuilder sb = new StringBuilder(indicesAndChars.array1.length);
- int i;
- for (i = 0; i < indicesAndChars.start1; i++)
- sb.append(indicesAndChars.array1[i]);
- for (i = indicesAndChars.start1; i < indicesAndChars.end1; i++)
- sb.append(LispCharacter.toUpperCase(indicesAndChars.array1[i]));
- for (i = indicesAndChars.end1;
- i < indicesAndChars.array1.length; i++)
- sb.append(indicesAndChars.array1[i]);
- return new SimpleString(sb);
+ char[] array = new char[indicesAndChars.array1.length];
+ System.arraycopy(indicesAndChars.array1, 0,
+ array, 0,
+ indicesAndChars.start1);
+ for (int i = indicesAndChars.start1; i < indicesAndChars.end1; i++)
+ array[i] = LispCharacter.toUpperCase(indicesAndChars.array1[i]);
+ System.arraycopy(indicesAndChars.array1, indicesAndChars.end1,
+ array, indicesAndChars.end1,
+ indicesAndChars.array1.length
+ - indicesAndChars.end1);
+ return new SimpleString(array);
}
};
@@ -580,16 +581,17 @@
LispObject third) {
StringIndicesAndChars indicesAndChars =
stringIndicesAndChars(first, second, third);
- StringBuilder sb = new StringBuilder(indicesAndChars.array1.length);
- int i;
- for (i = 0; i < indicesAndChars.start1; i++)
- sb.append(indicesAndChars.array1[i]);
- for (i = indicesAndChars.start1; i < indicesAndChars.end1; i++)
- sb.append(LispCharacter.toLowerCase(indicesAndChars.array1[i]));
- for (i = indicesAndChars.end1;
- i < indicesAndChars.array1.length; i++)
- sb.append(indicesAndChars.array1[i]);
- return new SimpleString(sb);
+ char[] array = new char[indicesAndChars.array1.length];
+ System.arraycopy(indicesAndChars.array1, 0,
+ array, 0,
+ indicesAndChars.start1);
+ for (int i = indicesAndChars.start1; i < indicesAndChars.end1; i++)
+ array[i] = LispCharacter.toLowerCase(indicesAndChars.array1[i]);
+ System.arraycopy(indicesAndChars.array1, indicesAndChars.end1,
+ array, indicesAndChars.end1,
+ indicesAndChars.array1.length
+ - indicesAndChars.end1);
+ return new SimpleString(array);
}
};
@@ -607,28 +609,32 @@
{
StringIndicesAndChars indicesAndChars =
stringIndicesAndChars(first, second, third);
- StringBuilder sb = new StringBuilder(indicesAndChars.array1.length);
+ char[] array = new char[indicesAndChars.array1.length];
boolean lastCharWasAlphanumeric = false;
- int i;
- for (i = 0; i < indicesAndChars.start1; i++)
- sb.append(indicesAndChars.array1[i]);
- for (i = indicesAndChars.start1; i < indicesAndChars.end1; i++) {
+ System.arraycopy(indicesAndChars.array1, 0,
+ array, 0,
+ indicesAndChars.start1);
+ for (int i = indicesAndChars.start1;
+ i < indicesAndChars.end1; i++) {
char c = indicesAndChars.array1[i];
if (Character.isLowerCase(c)) {
- sb.append(lastCharWasAlphanumeric ? c : LispCharacter.toUpperCase(c));
+ array[i] = lastCharWasAlphanumeric ?
+ c : LispCharacter.toUpperCase(c);
lastCharWasAlphanumeric = true;
} else if (Character.isUpperCase(c)) {
- sb.append(lastCharWasAlphanumeric ? LispCharacter.toLowerCase(c) : c);
+ array[i] = lastCharWasAlphanumeric ?
+ LispCharacter.toLowerCase(c) : c;
lastCharWasAlphanumeric = true;
} else {
- sb.append(c);
+ array[i] = c;
lastCharWasAlphanumeric = Character.isDigit(c);
}
}
- for (i = indicesAndChars.end1;
- i < indicesAndChars.array1.length; i++)
- sb.append(indicesAndChars.array1[i]);
- return new SimpleString(sb);
+ System.arraycopy(indicesAndChars.array1, indicesAndChars.end1,
+ array, indicesAndChars.end1,
+ indicesAndChars.array1.length
+ - indicesAndChars.end1);
+ return new SimpleString(array);
}
};
More information about the armedbear-cvs
mailing list