@@ -50,21 +50,6 @@ trait LinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with LinearSeq
50
50
51
51
override def isDefinedAt (x : Int ): Boolean = x >= 0 && lengthCompare(x) > 0
52
52
53
- // Optimized version of `drop` that avoids copying
54
- override def drop (n : Int ): C = {
55
- @ tailrec def loop (n : Int , s : C ): C =
56
- if (n <= 0 || s.isEmpty) s
57
- else loop(n - 1 , s.tail)
58
- loop(n, coll)
59
- }
60
-
61
- override def dropWhile (p : A => Boolean ): C = {
62
- @ tailrec def loop (s : C ): C =
63
- if (s.nonEmpty && p(s.head)) loop(s.tail)
64
- else s
65
- loop(coll)
66
- }
67
-
68
53
// `apply` is defined in terms of `drop`, which is in turn defined in
69
54
// terms of `tail`.
70
55
@ throws[IndexOutOfBoundsException ]
@@ -184,6 +169,21 @@ trait StrictOptimizedLinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A]
184
169
def hasNext = ! current.isEmpty
185
170
def next () = { val r = current.head; current = current.tail; r }
186
171
}
172
+
173
+ // Optimized version of `drop` that avoids copying
174
+ override def drop (n : Int ): C = {
175
+ @ tailrec def loop (n : Int , s : C ): C =
176
+ if (n <= 0 || s.isEmpty) s
177
+ else loop(n - 1 , s.tail)
178
+ loop(n, coll)
179
+ }
180
+
181
+ override def dropWhile (p : A => Boolean ): C = {
182
+ @ tailrec def loop (s : C ): C =
183
+ if (s.nonEmpty && p(s.head)) loop(s.tail)
184
+ else s
185
+ loop(coll)
186
+ }
187
187
}
188
188
189
189
/** A specialized Iterator for LinearSeqs that is lazy enough for Stream and LazyList. This is accomplished by not
0 commit comments