зеркало из https://github.com/mozilla/pjs.git
Replace instances of append("x") with append('x') on StringBuffers,
removing the need for String object instances.
This commit is contained in:
Родитель
efcd148780
Коммит
8d04f836a9
|
@ -332,7 +332,7 @@ public class BaseFunction extends IdScriptable implements Function {
|
|||
int i;
|
||||
for (i = 0; i < arglen - 1; i++) {
|
||||
if (i > 0)
|
||||
funArgs.append(",");
|
||||
funArgs.append(',');
|
||||
funArgs.append(ScriptRuntime.toString(args[i]));
|
||||
}
|
||||
String funBody = arglen == 0 ? "" : ScriptRuntime.toString(args[i]);
|
||||
|
|
|
@ -454,7 +454,7 @@ public class NativeArray extends IdScriptable {
|
|||
String separator;
|
||||
|
||||
if (toSource) {
|
||||
result.append("[");
|
||||
result.append('[');
|
||||
separator = ", ";
|
||||
} else {
|
||||
separator = ",";
|
||||
|
@ -476,10 +476,10 @@ public class NativeArray extends IdScriptable {
|
|||
|
||||
if (elem instanceof String) {
|
||||
if (toSource) {
|
||||
result.append("\"");
|
||||
result.append('\"');
|
||||
result.append(ScriptRuntime.escapeString
|
||||
(ScriptRuntime.toString(elem)));
|
||||
result.append("\"");
|
||||
result.append('\"');
|
||||
} else {
|
||||
result.append(ScriptRuntime.toString(elem));
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ public class NativeArray extends IdScriptable {
|
|||
if (!haslast && i > 0)
|
||||
result.append(", ]");
|
||||
else
|
||||
result.append("]");
|
||||
result.append(']');
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
|
|
@ -1047,36 +1047,36 @@ public class NativeDate extends IdScriptable {
|
|||
|
||||
if (format != FORMATSPEC_TIME) {
|
||||
result.append(days[WeekDay(local)]);
|
||||
result.append(" ");
|
||||
result.append(' ');
|
||||
result.append(months[MonthFromTime(local)]);
|
||||
if (dateStr.length() == 1)
|
||||
result.append(" 0");
|
||||
else
|
||||
result.append(" ");
|
||||
result.append(' ');
|
||||
result.append(dateStr);
|
||||
result.append(" ");
|
||||
result.append(' ');
|
||||
}
|
||||
|
||||
if (format != FORMATSPEC_DATE) {
|
||||
if (hourStr.length() == 1)
|
||||
result.append("0");
|
||||
result.append('0');
|
||||
result.append(hourStr);
|
||||
if (minStr.length() == 1)
|
||||
result.append(":0");
|
||||
else
|
||||
result.append(":");
|
||||
result.append(':');
|
||||
result.append(minStr);
|
||||
if (secStr.length() == 1)
|
||||
result.append(":0");
|
||||
else
|
||||
result.append(":");
|
||||
result.append(':');
|
||||
result.append(secStr);
|
||||
if (offset > 0)
|
||||
result.append(" GMT+");
|
||||
else
|
||||
result.append(" GMT-");
|
||||
for (int i = offsetStr.length(); i < 4; i++)
|
||||
result.append("0");
|
||||
result.append('0');
|
||||
result.append(offsetStr);
|
||||
|
||||
if (timeZoneFormatter == null)
|
||||
|
@ -1086,17 +1086,17 @@ public class NativeDate extends IdScriptable {
|
|||
result.append(" (");
|
||||
java.util.Date date = new Date((long) t);
|
||||
result.append(timeZoneFormatter.format(date));
|
||||
result.append(")");
|
||||
result.append(')');
|
||||
}
|
||||
if (format != FORMATSPEC_TIME)
|
||||
result.append(" ");
|
||||
result.append(' ');
|
||||
}
|
||||
|
||||
if (format != FORMATSPEC_TIME) {
|
||||
if (year < 0)
|
||||
result.append("-");
|
||||
result.append('-');
|
||||
for (int i = yearStr.length(); i < 4; i++)
|
||||
result.append("0");
|
||||
result.append('0');
|
||||
result.append(yearStr);
|
||||
}
|
||||
|
||||
|
@ -1230,33 +1230,33 @@ public class NativeDate extends IdScriptable {
|
|||
result.append(days[WeekDay(date)]);
|
||||
result.append(", ");
|
||||
if (dateStr.length() == 1)
|
||||
result.append("0");
|
||||
result.append('0');
|
||||
result.append(dateStr);
|
||||
result.append(" ");
|
||||
result.append(' ');
|
||||
result.append(months[MonthFromTime(date)]);
|
||||
if (year < 0)
|
||||
result.append(" -");
|
||||
else
|
||||
result.append(" ");
|
||||
result.append(' ');
|
||||
int i;
|
||||
for (i = yearStr.length(); i < 4; i++)
|
||||
result.append("0");
|
||||
result.append('0');
|
||||
result.append(yearStr);
|
||||
|
||||
if (hourStr.length() == 1)
|
||||
result.append(" 0");
|
||||
else
|
||||
result.append(" ");
|
||||
result.append(' ');
|
||||
result.append(hourStr);
|
||||
if (minStr.length() == 1)
|
||||
result.append(":0");
|
||||
else
|
||||
result.append(":");
|
||||
result.append(':');
|
||||
result.append(minStr);
|
||||
if (secStr.length() == 1)
|
||||
result.append(":0");
|
||||
else
|
||||
result.append(":");
|
||||
result.append(':');
|
||||
result.append(secStr);
|
||||
|
||||
result.append(" GMT");
|
||||
|
|
|
@ -324,7 +324,7 @@ public class NativeFunction extends BaseFunction {
|
|||
case TokenStream.LC:
|
||||
if (nextIs(i, TokenStream.EOL))
|
||||
indent += OFFSET;
|
||||
result.append("{");
|
||||
result.append('{');
|
||||
break;
|
||||
|
||||
case TokenStream.RC:
|
||||
|
@ -491,7 +491,7 @@ public class NativeFunction extends BaseFunction {
|
|||
case TokenStream.SEMI:
|
||||
if (nextIs(i, TokenStream.EOL))
|
||||
// statement termination
|
||||
result.append(";");
|
||||
result.append(';');
|
||||
else
|
||||
// separators in FOR
|
||||
result.append("; ");
|
||||
|
@ -565,7 +565,7 @@ public class NativeFunction extends BaseFunction {
|
|||
case TokenStream.COLON:
|
||||
if (nextIs(i, TokenStream.EOL))
|
||||
// it's the end of a label
|
||||
result.append(":");
|
||||
result.append(':');
|
||||
else
|
||||
// it's the middle part of a ternary
|
||||
result.append(" : ");
|
||||
|
|
|
@ -181,7 +181,7 @@ public class NativeObject extends IdScriptable {
|
|||
}
|
||||
}
|
||||
}
|
||||
result.append("}");
|
||||
result.append('}');
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -384,7 +384,7 @@ public class Node implements Cloneable {
|
|||
if (Context.printTrees) {
|
||||
StringBuffer sb = new StringBuffer(TokenStream.tokenToName(type));
|
||||
if (type == TokenStream.TARGET) {
|
||||
sb.append(" ");
|
||||
sb.append(' ');
|
||||
sb.append(hashCode());
|
||||
}
|
||||
if (datum != null) {
|
||||
|
@ -419,7 +419,7 @@ public class Node implements Cloneable {
|
|||
sb.append(elem.toString());
|
||||
break;
|
||||
}
|
||||
sb.append("]");
|
||||
sb.append(']');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
@ -395,7 +395,7 @@ public class ScriptRuntime {
|
|||
// cool idiom courtesy Shaver.
|
||||
result.append("\\u");
|
||||
for (int l = hex.length(); l < 4; l++)
|
||||
result.append("0");
|
||||
result.append('0');
|
||||
result.append(hex);
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ public class InvokerImpl extends Invoker {
|
|||
StringBuffer params = new StringBuffer(2 + ((types!=null)?(20 *
|
||||
types.length):0));
|
||||
|
||||
params.append("(");
|
||||
params.append('(');
|
||||
if (types != null) {
|
||||
for(int i = 0; i < types.length; i++) {
|
||||
Class type = types[i];
|
||||
|
@ -167,37 +167,37 @@ public class InvokerImpl extends Invoker {
|
|||
cfw.add(ByteCode.CHECKCAST, "java/lang/Boolean");
|
||||
cfw.add(ByteCode.INVOKEVIRTUAL, "java/lang/Boolean",
|
||||
"booleanValue", "()", "Z");
|
||||
params.append("Z");
|
||||
params.append('Z');
|
||||
} else if (type == Integer.TYPE) {
|
||||
cfw.add(ByteCode.CHECKCAST, "java/lang/Number");
|
||||
cfw.add(ByteCode.INVOKEVIRTUAL, "java/lang/Number",
|
||||
"intValue", "()", "I");
|
||||
params.append("I");
|
||||
params.append('I');
|
||||
} else if (type == Short.TYPE) {
|
||||
cfw.add(ByteCode.CHECKCAST, "java/lang/Number");
|
||||
cfw.add(ByteCode.INVOKEVIRTUAL, "java/lang/Number",
|
||||
"shortValue", "()", "S");
|
||||
params.append("S");
|
||||
params.append('S');
|
||||
} else if (type == Character.TYPE) {
|
||||
cfw.add(ByteCode.CHECKCAST, "java/lang/Character");
|
||||
cfw.add(ByteCode.INVOKEVIRTUAL, "java/lang/Character",
|
||||
"charValue", "()", "C");
|
||||
params.append("C");
|
||||
params.append('C');
|
||||
} else if (type == Double.TYPE) {
|
||||
cfw.add(ByteCode.CHECKCAST, "java/lang/Number");
|
||||
cfw.add(ByteCode.INVOKEVIRTUAL, "java/lang/Number",
|
||||
"doubleValue", "()", "D");
|
||||
params.append("D");
|
||||
params.append('D');
|
||||
} else if (type == Float.TYPE) {
|
||||
cfw.add(ByteCode.CHECKCAST, "java/lang/Number");
|
||||
cfw.add(ByteCode.INVOKEVIRTUAL, "java/lang/Number",
|
||||
"floatValue", "()", "F");
|
||||
params.append("F");
|
||||
params.append('F');
|
||||
} else if (type == Byte.TYPE) {
|
||||
cfw.add(ByteCode.CHECKCAST, "java/lang/Byte");
|
||||
cfw.add(ByteCode.INVOKEVIRTUAL, "java/lang/Byte",
|
||||
"byteValue", "()", "B");
|
||||
params.append("B");
|
||||
params.append('B');
|
||||
}
|
||||
} else {
|
||||
String typeName = type.getName().replace('.', '/');
|
||||
|
@ -214,7 +214,7 @@ public class InvokerImpl extends Invoker {
|
|||
}
|
||||
}
|
||||
}
|
||||
params.append(")");
|
||||
params.append(')');
|
||||
|
||||
// Call actual function!
|
||||
if (!java.lang.reflect.Modifier.isStatic(method.getModifiers())) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче