aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-04-07 22:57:30 +0200
committerMartin Odersky <odersky@gmail.com>2013-04-07 22:57:30 +0200
commit34cdca9f2eb60facef679cca9c1d7cb4b2ae10dc (patch)
tree83592bd64e2d5f1c2c4f0c55fdb5f6526ea41e38 /src/dotty
parentde1684b2daa4e23ff825965f4956e65410917a71 (diff)
downloaddotty-34cdca9f2eb60facef679cca9c1d7cb4b2ae10dc.tar.gz
dotty-34cdca9f2eb60facef679cca9c1d7cb4b2ae10dc.tar.bz2
dotty-34cdca9f2eb60facef679cca9c1d7cb4b2ae10dc.zip
Added filter utility method to Scope…
… which is more efficient than toList.filter.
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/core/Scopes.scala14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala
index 85104f30f..6bcfc6f6a 100644
--- a/src/dotty/tools/dotc/core/Scopes.scala
+++ b/src/dotty/tools/dotc/core/Scopes.scala
@@ -288,11 +288,15 @@ object Scopes {
override def foreach[U](p: Symbol => U): Unit = toList foreach p
- final def filteredScope(p: Symbol => Boolean)(implicit ctx: Context): MutableScope = {
- val unfiltered = toList
- val filtered = unfiltered filterConserve p
- if (filtered eq unfiltered) this
- else newScopeWith(filtered: _*)
+ override def filter(p: Symbol => Boolean): List[Symbol] = {
+ var syms: List[Symbol] = Nil
+ var e = lastEntry
+ while ((e ne null) && e.owner == this) {
+ val sym = e.sym
+ if (p(sym)) syms = sym :: syms
+ e = e.prev
+ }
+ syms
}
}