diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-01-20 13:27:15 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-01-20 13:27:15 +0100 |
commit | 7443037a6d1376709b3d83f10e66c9155f76dbaa (patch) | |
tree | a84a2db06b30ae9973b41c443bbe141b5582356e /src/compiler | |
parent | 4eee5e088eb72ba00aa4b02a03a1bcf27b5d751b (diff) | |
download | scala-7443037a6d1376709b3d83f10e66c9155f76dbaa.tar.gz scala-7443037a6d1376709b3d83f10e66c9155f76dbaa.tar.bz2 scala-7443037a6d1376709b3d83f10e66c9155f76dbaa.zip |
Precompile some regexes used in the backend
Diffstat (limited to 'src/compiler')
3 files changed, 12 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala b/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala index 739b775e56..baf82032f7 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala @@ -147,10 +147,10 @@ class BackendUtils[BT <: BTypes](val btypes: BT) { def getBoxedUnit: FieldInsnNode = new FieldInsnNode(Opcodes.GETSTATIC, coreBTypes.srBoxedUnitRef.internalName, "UNIT", coreBTypes.srBoxedUnitRef.descriptor) - private val anonfunAdaptedName = """.*\$anonfun\$\d+\$adapted""" + private val anonfunAdaptedName = """.*\$anonfun\$\d+\$adapted""".r def hasAdaptedImplMethod(closureInit: ClosureInstantiation): Boolean = { BytecodeUtils.isrJFunctionType(Type.getReturnType(closureInit.lambdaMetaFactoryCall.indy.desc).getInternalName) && - closureInit.lambdaMetaFactoryCall.implMethod.getName.matches(anonfunAdaptedName) + anonfunAdaptedName.pattern.matcher(closureInit.lambdaMetaFactoryCall.implMethod.getName).matches } /** diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/BoxUnbox.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/BoxUnbox.scala index a8829b6e29..4ecaf17a10 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/opt/BoxUnbox.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/BoxUnbox.scala @@ -763,9 +763,14 @@ class BoxUnbox[BT <: BTypes](val btypes: BT) { } } - private def isSpecializedTupleClass(tupleClass: InternalName) = tupleClass matches "scala/Tuple[12]\\$mc[IJDCZ]{1,2}\\$sp" - private def isSpecializedTupleGetter(mi: MethodInsnNode) = mi.name matches "_[12]\\$mc[IJDCZ]\\$sp" - private def isTupleGetter(mi: MethodInsnNode) = mi.name matches "_\\d\\d?" + private val specializedTupleClassR = "scala/Tuple[12]\\$mc[IJDCZ]{1,2}\\$sp".r + private def isSpecializedTupleClass(tupleClass: InternalName) = specializedTupleClassR.pattern.matcher(tupleClass).matches + + private val specializedTupleGetterR = "_[12]\\$mc[IJDCZ]\\$sp".r + private def isSpecializedTupleGetter(mi: MethodInsnNode) = specializedTupleGetterR.pattern.matcher(mi.name)matches + + private val tupleGetterR = "_\\d\\d?".r + private def isTupleGetter(mi: MethodInsnNode) = tupleGetterR.pattern.matcher(mi.name).matches def checkTupleExtraction(insn: AbstractInsnNode, kind: Tuple, prodCons: ProdConsAnalyzer): Option[BoxConsumer] = { val expectedTupleClass = kind.tupleClass diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala index a041af2621..35bc82d098 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala @@ -218,7 +218,7 @@ class ClosureOptimizer[BT <: BTypes](val btypes: BT) { receiverProducers.size == 1 && receiverProducers.head == indy } - def isSpecializedVersion(specName: String, nonSpecName: String) = specName.startsWith(nonSpecName) && specName.substring(nonSpecName.length).matches(specializationSuffix) + def isSpecializedVersion(specName: String, nonSpecName: String) = specName.startsWith(nonSpecName) && specializationSuffix.pattern.matcher(specName.substring(nonSpecName.length)).matches def sameOrSpecializedType(specTp: Type, nonSpecTp: Type) = { specTp == nonSpecTp || { @@ -517,5 +517,5 @@ class ClosureOptimizer[BT <: BTypes](val btypes: BT) { object ClosureOptimizer { val primitives = "BSIJCFDZV" - val specializationSuffix = s"(\\$$mc[$primitives]+\\$$sp)" + val specializationSuffix = s"(\\$$mc[$primitives]+\\$$sp)".r } |