Oliver Jowett wrote:
> Ken Geis wrote:
>
>> I changed the line
>>
>> byte[][] answer = new byte[l_nf][0];
>> to
>> byte[][] answer = new byte[l_nf][];
>>
>> This gave ~1% increase on the benchmark I was running.
>
>
> Gah?! What JVM? Aren't the two forms equivalent?
Hmm, after some experimentation, they do produce different bytecode
(multianewarray vs. anewarray):
public void testit() {
byte[][] dummy = new byte[10][0];
byte[][] dummy2 = new byte[10][];
}
public void testit();
Code:
0: bipush 10
2: iconst_0
3: multianewarray #2, 2; //class "[[B"
7: astore_1
8: bipush 10
10: anewarray #3; //class "[B"
13: astore_2
14: return
Interesting to know it makes a performance difference. What JVM did you
test on?
-O