File tree Expand file tree Collapse file tree 2 files changed +17
-15
lines changed
main/scala/scala/util/parsing/input
test/scala/scala/util/parsing/input Expand file tree Collapse file tree 2 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -41,21 +41,8 @@ object PagedSeq {
4141 fromIterator(source.iterator)
4242
4343 /** Constructs a paged character sequence from a string iterator */
44- def fromStrings (source : Iterator [String ]): PagedSeq [Char ] = {
45- var current : String = " "
46- def more (data : Array [Char ], start : Int , len : Int ): Int =
47- if (current.length != 0 ) {
48- val cnt = current.length min len
49- current.getChars(0 , cnt, data, start)
50- current = current.substring(cnt)
51- if (cnt == len) cnt
52- else (more(data, start + cnt, len - cnt) max 0 ) + cnt
53- } else if (source.hasNext) {
54- current = source.next()
55- more(data, start, len)
56- } else - 1
57- new PagedSeq (more(_ : Array [Char ], _ : Int , _ : Int ))
58- }
44+ def fromStrings (source : Iterator [String ]): PagedSeq [Char ] =
45+ fromIterator(source.flatMap(_.iterator))
5946
6047 /** Constructs a paged character sequence from a string iterable */
6148 def fromStrings (source : Iterable [String ]): PagedSeq [Char ] =
Original file line number Diff line number Diff line change 1+ package scala .util .parsing .input
2+
3+ import org .junit .Assert .assertEquals
4+ import org .junit .Test
5+
6+ class gh178 {
7+
8+ @ Test
9+ def test : Unit = {
10+ val len = 100000
11+ val i = Iterator .fill(len)(" A" )
12+ val pagedSeq = PagedSeq .fromStrings(i)
13+ assertEquals(len, pagedSeq.slice(0 ).length) // should not fail with StackOverflowError
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments