Skip to content

Commit 2f66995

Browse files
committed
Use sliding to simplify the code
1 parent a3a41bb commit 2f66995

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TastyString.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@ object TastyString {
1515
/** Encode TASTY bytes into an Seq of String */
1616
def pickle(bytes: Array[Byte]): Pickled = {
1717
val str = new String(Base64.getEncoder().encode(bytes), UTF_8)
18-
def split(sliceEnd: Int, acc: List[String]): List[String] = {
19-
if (sliceEnd == 0) acc
20-
else {
21-
val sliceStart = (sliceEnd - maxStringSize) max 0
22-
split(sliceStart, str.substring(sliceStart, sliceEnd) :: acc)
23-
}
24-
}
25-
split(str.length, Nil)
18+
str.sliding(maxStringSize, maxStringSize).toList
2619
}
2720

2821
/** Decode the TASTY String into TASTY bytes */

0 commit comments

Comments
 (0)