Skip to content

Commit 6926796

Browse files
nicolasstuckiallanrenucci
authored andcommitted
Make inline foldLeftBN into foldRightBN to avoid reversed params
1 parent c59b8d0 commit 6926796

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

compiler/src/dotty/tools/dotc/core/Decorators.scala

+4-7
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,12 @@ object Decorators {
112112
else x1 :: xs1
113113
}
114114

115-
def foldRightBN[U](z: => U)(op: (T, => U) => U): U =
116-
xs.reverse.foldLeftBN(z)(op)
117-
118-
final def foldLeftBN[U](acc: => U)(op: (T, => U) => U): U = {
119-
@tailrec def fold(xs: List[T], acc: => U): U = xs match {
120-
case x :: xs1 => fold(xs1, op(x, acc))
115+
def foldRightBN[U](z: => U)(op: (T, => U) => U): U = {
116+
@tailrec def foldLeftBN(xs: List[T], acc: => U): U = xs match {
117+
case x :: xs1 => foldLeftBN(xs1, op(x, acc))
121118
case Nil => acc
122119
}
123-
fold(xs, acc)
120+
foldLeftBN(xs.reverse, z)
124121
}
125122

126123
final def hasSameLengthAs[U](ys: List[U]): Boolean = {

0 commit comments

Comments
 (0)