diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2007-05-01 08:09:25 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2007-05-01 08:09:25 +0000 |
commit | c90d5a4256717a4cbcfbefdef4b0109834e475c9 (patch) | |
tree | 9c321ffb7e4145c9f90bd03b7f305b3528cb63c8 /src | |
parent | 7f42043da32f8b328293b41ddce8d0c380447baf (diff) | |
download | scala-c90d5a4256717a4cbcfbefdef4b0109834e475c9.tar.gz scala-c90d5a4256717a4cbcfbefdef4b0109834e475c9.tar.bz2 scala-c90d5a4256717a4cbcfbefdef4b0109834e475c9.zip |
Use StringBuilder instead of StringBuffer when ...
Use StringBuilder instead of StringBuffer when compiling for 'jvm-1.5'
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index b55389216c..41b7db1e18 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -56,9 +56,9 @@ abstract class GenJVM extends SubComponent { */ class BytecodeGenerator { val MIN_SWITCH_DENSITY = 0.7 - val JAVA_LANG_STRINGBUFFER = "java.lang.StringBuffer" + val StringBufferClass = if (settings.target.value == "jvm-1.5") "java.lang.StringBuilder" else "java.lang.StringBuffer" - val stringBufferType = new JObjectType(JAVA_LANG_STRINGBUFFER) + val stringBufferType = new JObjectType(StringBufferClass) val toStringType = new JMethodType(JObjectType.JAVA_LANG_STRING, JType.EMPTY_ARRAY) def attributeType(name: String) = @@ -1146,9 +1146,9 @@ abstract class GenJVM extends SubComponent { jcode.emitARRAYLENGTH() case StartConcat => - jcode.emitNEW(JAVA_LANG_STRINGBUFFER) + jcode.emitNEW(StringBufferClass) jcode.emitDUP() - jcode.emitINVOKESPECIAL(JAVA_LANG_STRINGBUFFER, + jcode.emitINVOKESPECIAL(StringBufferClass, JMethod.INSTANCE_CONSTRUCTOR_NAME, JMethodType.ARGLESS_VOID_FUNCTION) @@ -1157,12 +1157,12 @@ abstract class GenJVM extends SubComponent { case REFERENCE(_) | ARRAY(_)=> JObjectType.JAVA_LANG_OBJECT case _ => javaType(el) } - jcode.emitINVOKEVIRTUAL(JAVA_LANG_STRINGBUFFER, + jcode.emitINVOKEVIRTUAL(StringBufferClass, "append", new JMethodType(stringBufferType, Array(jtype))) case EndConcat => - jcode.emitINVOKEVIRTUAL(JAVA_LANG_STRINGBUFFER, + jcode.emitINVOKEVIRTUAL(StringBufferClass, "toString", toStringType) |