Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is there a performance difference between these two code  RSS feed

 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Version 1:

Which disassembles into:
public class InitArrayTest extends java.lang.Object {
public InitArrayTest();
public static void main(java.lang.String[]);
}
Method InitArrayTest()
0 aload_0
1 invokespecial #1 <Method java.lang.Object()>
4 return
Method void main(java.lang.String[])
0 iconst_1
1 newarray int
3 astore_1
4 aload_1
5 iconst_0
6 iconst_1
7 iastore
8 return
/*******************************************************/
Version 2:

Which disassembles into:
Compiled from InitArrayTest.java
public class InitArrayTest extends java.lang.Object {
public InitArrayTest();
public static void main(java.lang.String[]);
}
Method InitArrayTest()
0 aload_0
1 invokespecial #1 <Method java.lang.Object()>
4 return
Method void main(java.lang.String[])
0 iconst_1
1 newarray int
3 dup
4 iconst_0
5 iconst_1
6 iastore
7 astore_1
8 return
Thanks,
-Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!