Make test 1946 faster

On overloaded machines test 1946 will sometimes time-out. To make this
test faster we will turn one of the lists into a HashMap and using
lambdas to delay expensive Arrays.toString calls. This leads to the
test being around 70% faster.

Pre-change:
% time ./test/run-test --host --dev --64 1946
<snip>
./test/run-test --host --dev --64 1946  36.28s user 25.57s system 277% cpu 22.286 total

Post-change:
% time ./test/run-test --host --dev --64 1946
<snip>
./test/run-test --host --dev --64 1946  19.06s user 26.78s system 724% cpu 6.329 total

Test: ./test.py --host
Bug: 74583462
Change-Id: Id9b761ae95f87c96c0eb2fcdf5355a804d396267
diff --git a/test/1946-list-descriptors/src-art/art/Test1946.java b/test/1946-list-descriptors/src-art/art/Test1946.java
index 3e5ec65..19032c8 100644
--- a/test/1946-list-descriptors/src-art/art/Test1946.java
+++ b/test/1946-list-descriptors/src-art/art/Test1946.java
@@ -17,6 +17,7 @@
 package art;
 
 import java.util.*;
+import java.util.function.*;
 import java.lang.reflect.*;
 import java.nio.ByteBuffer;
 import dalvik.system.InMemoryDexClassLoader;
@@ -49,22 +50,24 @@
   public class TMP2 {}
   public class TMP3 extends ArrayList {}
 
-  private static void check(boolean b, String msg) {
+  private static void check(boolean b, Supplier<String> msg) {
     if (!b) {
-      throw new Error("Test failed! " + msg);
+      throw new Error("Test failed! " + msg.get());
     }
   }
 
-  private static <T> void checkEq(T[] full, T[] sub, String msg) {
+  private static <T> void checkEq(T[] full, T[] sub, final String msg) {
     List<T> f = Arrays.asList(full);
-    check(full.length == sub.length, "not equal length");
-    msg = Arrays.toString(full) + " is not same as " + Arrays.toString(sub) + ": " + msg;
-    check(Arrays.asList(full).containsAll(Arrays.asList(sub)), msg);
+    check(full.length == sub.length, () -> "not equal length");
+    Supplier<String> msgGen =
+      () -> Arrays.toString(full) + " is not same as " + Arrays.toString(sub) + ": " + msg;
+    check(new HashSet<T>(Arrays.asList(full)).containsAll(Arrays.asList(sub)), msgGen);
   }
 
-  private static <T> void checkSubset(T[] full, T[] sub, String msg) {
-    msg = Arrays.toString(full) + " does not contain all of " + Arrays.toString(sub) + ": " + msg;
-    check(Arrays.asList(full).containsAll(Arrays.asList(sub)), msg);
+  private static <T> void checkSubset(T[] full, T[] sub, final String msg) {
+    Supplier<String> msgGen =
+      () -> Arrays.toString(full) + " does not contain all of " + Arrays.toString(sub) + ": " + msg;
+    check(new HashSet<T>(Arrays.asList(full)).containsAll(Arrays.asList(sub)), msgGen);
   }
 
   public static void run() throws Exception {