QuackatronHQ / Gigarepo

Consider combining successive .filter() calls SC-P1009
Performance
Major
a month ago2 years old
Consider combining both the filters
11  def exists(arr: Array[Int], criteria: Int => Boolean): Boolean                           = arr.find(criteria).isDefined
12  def filterBy(arr: Array[Int], criteria: Int => Boolean): Array[Int]                      = arr.filter(criteria)
13  def filterBy(arr: Array[Int], first: Int => Boolean, `then`: Int => Boolean): Array[Int] =
14    arr.filter(first).filter(`then`)15
16  def pickBy(arr: Array[Int], criteria: Int => Boolean): Unit = {
17    for (i <- 0 to arr.length - 1) {