Skip to content

Conversation

@bishabosha
Copy link
Member

previously in source it called arr.toSeq.forEach, relying on a potential flaky implicit conversion to scala.collection.immutable.ArraySeq and then a no-op .toSeq on top of that.

make the conversion explicit, so that it never uses Predef.genericWrapArray, which would copy when calling .toSeq

previously in source it called `arr.toSeq.forEach`, relying on a potential
flaky implicit conversion to scala.collection.immutable.ArraySeq.

make the conversion explicit, so that it never uses Predef.genericWrapArray, which would copy when calling .toSeq
@bishabosha bishabosha requested a review from a team as a code owner December 11, 2025 08:35
@bishabosha
Copy link
Member Author

bishabosha commented Dec 11, 2025

as evidence here is the old byte code (using IArray's own genericWrapArray):

public <T extends java.lang.Object, U extends java.lang.Object> java.lang.Object tapEach(java.lang.Object, scala.Function1<T, U>);
    descriptor: (Ljava/lang/Object;Lscala/Function1;)Ljava/lang/Object;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=3, args_size=3
         0: aload_0
         1: aload_1
         2: invokevirtual #414                // Method genericWrapArray:(Ljava/lang/Object;)Lscala/collection/immutable/ArraySeq;
         5: invokevirtual #418                // Method scala/collection/immutable/ArraySeq.toSeq:()Lscala/collection/immutable/Seq;
         8: aload_2
         9: invokeinterface #640,  2          // InterfaceMethod scala/collection/immutable/Seq.foreach:(Lscala/Function1;)V
        14: aload_1
        15: areturn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant