@@ -123,17 +123,30 @@ abstract class BTypes {
123
123
* has the method.
124
124
*/
125
125
val indyLambdaImplMethods : mutable.AnyRefMap [InternalName , mutable.LinkedHashSet [asm.Handle ]] = recordPerRunCache(mutable.AnyRefMap ())
126
+
127
+ /**
128
+ * add methods
129
+ * @return the added methods. Note the order is undefined
130
+ */
126
131
def addIndyLambdaImplMethod (hostClass : InternalName , handle : Seq [asm.Handle ]): Seq [asm.Handle ] = {
127
132
if (handle.isEmpty) Nil else {
128
133
val set = indyLambdaImplMethods.getOrElseUpdate(hostClass, mutable.LinkedHashSet ())
129
- val added = handle.filterNot(set)
130
- set ++= handle
131
- added
134
+ if (set isEmpty) {
135
+ set ++= handle
136
+ handle
137
+ } else {
138
+ var added = List .empty[asm.Handle ]
139
+ handle foreach { h => if (set.add(h)) added ::= h}
140
+ added
141
+ }
132
142
}
133
143
}
144
+ def addIndyLambdaImplMethod (hostClass : InternalName , handle : asm.Handle ): Boolean = {
145
+ indyLambdaImplMethods.getOrElseUpdate(hostClass, mutable.LinkedHashSet ()).add(handle)
146
+ }
134
147
def removeIndyLambdaImplMethod (hostClass : InternalName , handle : Seq [asm.Handle ]): Unit = {
135
148
if (handle.nonEmpty)
136
- indyLambdaImplMethods.getOrElseUpdate (hostClass, mutable. LinkedHashSet ()) --= handle
149
+ indyLambdaImplMethods.get (hostClass).foreach(_ --= handle)
137
150
}
138
151
139
152
def getIndyLambdaImplMethods (hostClass : InternalName ): Iterable [asm.Handle ] = {
@@ -258,7 +271,7 @@ abstract class BTypes {
258
271
def inlineInfoFromClassfile (classNode : ClassNode ): InlineInfo = {
259
272
def fromClassfileAttribute : Option [InlineInfo ] = {
260
273
if (classNode.attrs == null ) None
261
- else classNode.attrs.asScala.collect( { case a : InlineInfoAttribute => a}).headOption.map(_. inlineInfo)
274
+ else classNode.attrs.asScala.collectFirst { case a : InlineInfoAttribute => a. inlineInfo}
262
275
}
263
276
264
277
def fromClassfileWithoutAttribute = {
@@ -272,13 +285,13 @@ abstract class BTypes {
272
285
// require special handling. Excluding is OK because they are never inlined.
273
286
// Here we are parsing from a classfile and we don't need to do anything special. Many of these
274
287
// primitives don't even exist, for example Any.isInstanceOf.
275
- val methodInfos = classNode.methods.asScala.map(methodNode => {
288
+ val methodInfos : Map [ String , MethodInlineInfo ] = classNode.methods.asScala.map(methodNode => {
276
289
val info = MethodInlineInfo (
277
290
effectivelyFinal = BytecodeUtils .isFinalMethod(methodNode),
278
291
annotatedInline = false ,
279
292
annotatedNoInline = false )
280
293
(methodNode.name + methodNode.desc, info)
281
- }).toMap
294
+ })(scala.collection.breakOut)
282
295
InlineInfo (
283
296
isEffectivelyFinal = BytecodeUtils .isFinalClass(classNode),
284
297
sam = inlinerHeuristics.javaSam(classNode.name),
@@ -896,11 +909,6 @@ abstract class BTypes {
896
909
assert(info.get.nestedClasses.forall(c => ifInit(c)(_.isNestedClass.get)), info.get.nestedClasses)
897
910
}
898
911
899
- /**
900
- * @return The class name without the package prefix
901
- */
902
- def simpleName : String = internalName.split(" /" ).last
903
-
904
912
def isInterface : Either [NoClassBTypeInfo , Boolean ] = info.map(i => (i.flags & asm.Opcodes .ACC_INTERFACE ) != 0 )
905
913
906
914
def superClassesTransitive : Either [NoClassBTypeInfo , List [ClassBType ]] = info.flatMap(i => i.superClass match {
0 commit comments