rorygraves / scalac_perf

The Scala programming language
http://www.scala-lang.org/
16 stars 3 forks source link

Scope filtering #61

Open mkeskells opened 6 years ago

mkeskells commented 6 years ago
  override def filterNot(p: Symbol => Boolean): Scope = (
      if (toList exists p) newScopeWith(toList filterNot p: _*)
      else this
    )
    override def filter(p: Symbol => Boolean): Scope = (
      if (toList forall p) this
      else newScopeWith(toList filter p: _*)
    )

may iterate the list twice, and perform functions of known results (those previously examined)

note - toList is already cached

ackratos commented 6 years ago

do you mean we should:

override def filter(p: Symbol => Boolean): Scope = (
      val filtered = toList filter p
      if (filtered.size == toList.size) this
      else newScopeWith(filtered: _*)
)

If this looks good, I'd like take this one to play with latest perf_tester.