Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit argument array for contiguous numbered arguments
For strings which match, this reduces the generated bytecode impact. Each argument 'put' operation in the map required: 36: aload 6 38: ldc #99 // String 0 40: aload_1 41: invokevirtual #30 // Method android/util/ArrayMap.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; 44: pop plus the associated string pool constant's size. In the array, storage requires fewer bytecodes and bytecodes with fewer arguments reducing their size: 32: aload 7 34: iconst_0 35: aload_1 36: aastore Creating the map used to cost 10 bytes and require invoking the ArrayMap constructor: 26: new #23 // class android/util/ArrayMap 29: dup 30: iconst_5 31: invokespecial #26 // Method android/util/ArrayMap."<init>":(I)V 34: astore 6 But the array requires only 5 bytes and zero method calls: 27: anewarray #4 // class java/lang/Object 30: astore 7 Finally, previously, the `Map` property of the `FormattedResource` class required an explicit cast inside the generated code: 89: new #32 // class app/cash/gingham/FormattedResource 92: dup 93: ldc #108 // int 2131689631 95: aload 6 97: checkcast #35 // class java/util/Map 100: invokespecial #38 // Method app/cash/gingham/FormattedResource."<init>":(ILjava/util/Map;)V 103: areturn But with the property changing to `Any` (i.e., `Object`) the cast is no longer required for either the array-based or map-based generated code: 69: new #32 // class app/cash/gingham/FormattedResource 72: dup 73: ldc #96 // int 2131689631 75: aload 6 77: invokespecial #36 // Method app/cash/gingham/FormattedResource."<init>":(ILjava/lang/Object;)V 80: areturn
- Loading branch information