@@ -274,31 +274,29 @@ object DynamicTuple {
274
274
def dynamicConcat [This <: Tuple , That <: Tuple ](self : This , that : That ): Concat [This , That ] = {
275
275
type Result = Concat [This , That ]
276
276
277
+ val selfSize : Int = self.size
277
278
// If one of the tuples is empty, we can leave early
278
- (self : Any ) match {
279
- case self : Unit => return that.asInstanceOf [Result ]
280
- case _ =>
281
- }
279
+ if selfSize == 0 then
280
+ return that.asInstanceOf [Result ]
282
281
283
- (that : Any ) match {
284
- case that : Unit => return self.asInstanceOf [Result ]
285
- case _ =>
286
- }
282
+ val thatSize : Int = that.size
283
+ if thatSize == 0 then
284
+ return self.asInstanceOf [Result ]
287
285
288
- val arr = new Array [Object ](self.size + that.size )
286
+ val arr = new Array [Object ](selfSize + thatSize )
289
287
290
288
// Copies the tuple to an array, at the given offset
291
- inline def copyToArray [T <: Tuple ](tuple : T , array : Array [Object ], offset : Int ): Unit = (tuple : Any ) match {
289
+ inline def copyToArray [T <: Tuple ](tuple : T , size : Int , array : Array [Object ], offset : Int ): Unit = (tuple : Any ) match {
292
290
case xxl : TupleXXL =>
293
- System .arraycopy(xxl.elems, 0 , array, offset, tuple. size)
291
+ System .arraycopy(xxl.elems, 0 , array, offset, size)
294
292
case _ =>
295
293
tuple.asInstanceOf [Product ].productIterator.asInstanceOf [Iterator [Object ]]
296
- .copyToArray(array, offset, tuple. size)
294
+ .copyToArray(array, offset, size)
297
295
}
298
296
299
297
// In the general case, we copy the two tuples to an array, and convert it back to a tuple
300
- copyToArray(self, arr, 0 )
301
- copyToArray(that, arr, self.size )
298
+ copyToArray(self, selfSize, arr, 0 )
299
+ copyToArray(that, thatSize, arr, selfSize )
302
300
dynamicFromIArray[Result ](arr.asInstanceOf [IArray [Object ]])
303
301
}
304
302
@@ -401,9 +399,11 @@ object DynamicTuple {
401
399
}
402
400
403
401
def dynamicZip [This <: Tuple , T2 <: Tuple ](t1 : This , t2 : T2 ): Zip [This , T2 ] = {
404
- if (t1.size == 0 || t2.size == 0 ) return ().asInstanceOf [Zip [This , T2 ]]
405
- val size = Math .min(t1.size, t2.size)
406
- Tuple .fromIArray(
402
+ val t1Size : Int = t1.size
403
+ val t2Size : Int = t2.size
404
+ val size = Math .min(t1Size, t2Size)
405
+ if size == 0 then ().asInstanceOf [Zip [This , T2 ]]
406
+ else Tuple .fromIArray(
407
407
zipIterators(
408
408
t1.asInstanceOf [Product ].productIterator,
409
409
t2.asInstanceOf [Product ].productIterator,
@@ -475,7 +475,8 @@ object DynamicTuple {
475
475
476
476
def dynamicTake [This <: Tuple , N <: Int ](self : This , n : N ): Take [This , N ] = {
477
477
if (n < 0 ) throw new IndexOutOfBoundsException (n.toString)
478
- val actualN = Math .min(n, self.size)
478
+ val selfSize : Int = self.size
479
+ val actualN = Math .min(n, selfSize)
479
480
480
481
type Result = Take [This , N ]
481
482
0 commit comments