diff options
author | Paul Phillips <paulp@improving.org> | 2012-01-03 13:37:46 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-05 13:44:44 -0800 |
commit | 9b1f23680b9cb147f57d8967e1227c0a39cb0414 (patch) | |
tree | 1a8b0a62611442cc8b32658408a75b8cacb13c1d /src | |
parent | 97020945efb0b9d7eebebedce757548349c94537 (diff) | |
download | scala-9b1f23680b9cb147f57d8967e1227c0a39cb0414.tar.gz scala-9b1f23680b9cb147f57d8967e1227c0a39cb0414.tar.bz2 scala-9b1f23680b9cb147f57d8967e1227c0a39cb0414.zip |
Optimizing findMember.
Profiled for the most frequent drinkers at the findMember
tavern and gave them bracelets so they don't have to always
be hassling the bartender.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/reflect/internal/Definitions.scala | 18 | ||||
-rw-r--r-- | src/compiler/scala/reflect/internal/Types.scala | 16 |
2 files changed, 23 insertions, 11 deletions
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index 54c1153f81..900d62476c 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -101,9 +101,9 @@ trait Definitions extends reflect.api.StandardDefinitions { lazy val FloatClass = valueCache(tpnme.Float) lazy val DoubleClass = valueCache(tpnme.Double) lazy val BooleanClass = valueCache(tpnme.Boolean) - def Boolean_and = getMember(BooleanClass, nme.ZAND) - def Boolean_or = getMember(BooleanClass, nme.ZOR) - def Boolean_not = getMember(BooleanClass, nme.UNARY_!) + lazy val Boolean_and = getMember(BooleanClass, nme.ZAND) + lazy val Boolean_or = getMember(BooleanClass, nme.ZOR) + lazy val Boolean_not = getMember(BooleanClass, nme.UNARY_!) def ScalaValueClassesNoUnit = ScalaValueClasses filterNot (_ eq UnitClass) def ScalaValueClasses: List[Symbol] = List( @@ -343,12 +343,12 @@ trait Definitions extends reflect.api.StandardDefinitions { // arrays and their members lazy val ArrayModule = getModule("scala.Array") - def ArrayModule_overloadedApply = getMember(ArrayModule, nme.apply) + lazy val ArrayModule_overloadedApply = getMember(ArrayModule, nme.apply) lazy val ArrayClass = getClass("scala.Array") - def Array_apply = getMember(ArrayClass, nme.apply) - def Array_update = getMember(ArrayClass, nme.update) - def Array_length = getMember(ArrayClass, nme.length) - lazy val Array_clone = getMember(ArrayClass, nme.clone_) + lazy val Array_apply = getMember(ArrayClass, nme.apply) + lazy val Array_update = getMember(ArrayClass, nme.update) + lazy val Array_length = getMember(ArrayClass, nme.length) + lazy val Array_clone = getMember(ArrayClass, nme.clone_) // reflection / structural types lazy val SoftReferenceClass = getClass("java.lang.ref.SoftReference") @@ -376,7 +376,7 @@ trait Definitions extends reflect.api.StandardDefinitions { lazy val NoManifest = getModule("scala.reflect.NoManifest") lazy val CodeClass = getClass(sn.Code) lazy val CodeModule = getModule(sn.Code) - def Code_lift = getMember(CodeModule, nme.lift_) + lazy val Code_lift = getMember(CodeModule, nme.lift_) lazy val ScalaSignatureAnnotation = getClass("scala.reflect.ScalaSignature") lazy val ScalaLongSignatureAnnotation = getClass("scala.reflect.ScalaLongSignature") diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 0b6d77db07..844d6b79e3 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -537,6 +537,16 @@ trait Types extends api.Types { self: SymbolTable => */ def nonPrivateMember(name: Name): Symbol = memberBasedOnName(name, BridgeAndPrivateFlags) + + /** All members with the given flags, excluding bridges. + */ + def membersWithFlags(requiredFlags: Long): List[Symbol] = + membersBasedOnFlags(BridgeFlags, requiredFlags) + + /** All non-private members with the given flags, excluding bridges. + */ + def nonPrivateMembersWithFlags(requiredFlags: Long): List[Symbol] = + membersBasedOnFlags(BridgeAndPrivateFlags, requiredFlags) /** The non-private member with given name, admitting members with given flags `admit`. * "Admitting" refers to the fact that members with a PRIVATE, BRIDGE, or VBRIDGE @@ -552,7 +562,10 @@ trait Types extends api.Types { self: SymbolTable => * an OverloadedSymbol if several exist, NoSymbol if none exist */ def nonLocalMember(name: Name): Symbol = memberBasedOnName(name, BridgeFlags | LOCAL) - + + /** Members excluding and requiring the given flags. + * Note: unfortunately it doesn't work to exclude DEFERRED this way. + */ def membersBasedOnFlags(excludedFlags: Long, requiredFlags: Long): List[Symbol] = findMember(nme.ANYNAME, excludedFlags, requiredFlags, false).alternatives @@ -1017,7 +1030,6 @@ trait Types extends api.Types { self: SymbolTable => baseClasses.head.newOverloaded(this, members.toList) } } - /** The existential skolems and existentially quantified variables which are free in this type */ def existentialSkolems: List[Symbol] = { var boundSyms: List[Symbol] = List() |