Skip to content

Commit 8670d42

Browse files
committed
Use logic from DynamicTuple and remove duplicated methods
1 parent e358a1f commit 8670d42

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

library/src-3.x/scala/Tuple.scala

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import annotation.showAsInfix
33
import compiletime._
44
import internal._
55

6+
import scala.runtime.DynamicTuple
7+
68
sealed trait Tuple extends Any {
79
import Tuple._
810

@@ -22,8 +24,8 @@ sealed trait Tuple extends Any {
2224
case Some(4) =>
2325
val t = asInstanceOf[Tuple4[Object, Object, Object, Object]]
2426
Array(t._1, t._2, t._3, t._4)
25-
case Some(n) if n <= scala.runtime.DynamicTuple.MaxSpecialized =>
26-
to$Array(this, n)
27+
case Some(n) if n <= DynamicTuple.MaxSpecialized =>
28+
DynamicTuple.to$Array(this, n)
2729
case Some(n) =>
2830
asInstanceOf[TupleXXL].elems
2931
case None =>
@@ -47,7 +49,7 @@ sealed trait Tuple extends Any {
4749
val t = asInstanceOf[Tuple4[_, _, _, _]]
4850
Tuple5(x, t._1, t._2, t._3, t._4).asInstanceOf[Result]
4951
case Some(n) =>
50-
knowTupleFromArray[H *: this.type](cons$Array(x, toArray))
52+
knowTupleFromArray[H *: this.type](DynamicTuple.cons$Array(x, toArray))
5153
case _ =>
5254
runtime.DynamicTuple.dynamic_*:[This, H](this, x)
5355
}
@@ -143,24 +145,6 @@ object Tuple {
143145

144146
private[scala] val $emptyArray = Array[Object]()
145147

146-
def to$Array(xs: Tuple, n: Int) = {
147-
val arr = new Array[Object](n)
148-
var i = 0
149-
var it = xs.asInstanceOf[Product].productIterator
150-
while (i < n) {
151-
arr(i) = it.next().asInstanceOf[Object]
152-
i += 1
153-
}
154-
arr
155-
}
156-
157-
def cons$Array[H](x: H, elems: Array[Object]): Array[Object] = {
158-
val elems1 = new Array[Object](elems.length + 1)
159-
elems1(0) = x.asInstanceOf[Object]
160-
System.arraycopy(elems, 0, elems1, 1, elems.length)
161-
elems1
162-
}
163-
164148
private[scala] inline def knowTupleFromArray[T <: Tuple](xs: Array[Object]): T =
165149
inline constValue[BoundedSize[T]] match {
166150
case 0 => ().asInstanceOf[T]

0 commit comments

Comments
 (0)