- Joined
- Nov 30, 2007
- Messages
- 1,202
I'm sitting on the latest wc3 patch and when testing my code methods that should be inlined are not for me, where as for Overfrost who sits on older patch it seem to work fine. Could someone confirm this?
I've also tested this by removing the use of table and i hit on the OP limit much later, if the method inlined properly there would be no difference between using Table and not using Table in this regard.
I've also tested this by removing the use of table and i hit on the OP limit much later, if the method inlined properly there would be no difference between using Table and not using Table in this regard.
Since Overfrost didn't believe me when I said that Table doesn't inline I now have proof that method operators don't inline, or am I reading this result wrong? (I didn't actually look at Table but the principle is the same).
JASS:method operator[] takes integer index returns $TYPE$ return Load$VAR$(HashRecyler.ht , this, index) endmethod method operator[]= takes integer index, $TYPE$ element returns nothing call Save$VAR$(HashRecyler.ht , this, index, element) endmethod private method reverseInner takes integer first, integer last returns nothing if first < last then // this section should be inlined set other = this[first] set this[first] = this[last] set this[last] = other call .reverseInner(first + 1, last - 1) endif endmethod method reverse takes nothing returns nothing //call reverseInner(0, .length) set up = 0 set down = .length - 1 loop exitwhen down <= up set other = this[up] set this[up] = this[down] set this[down] = other set up = up + 1 set down = down - 1 endloop endmethod
Translates into:
This doesn't look like inlining to me.JASS:// Setter function s__IntArrayList__getindex takes integer this,integer index returns integer return LoadInteger(s__HashRecyler_ht, this, index) endfunction // Getter function s__IntArrayList__setindex takes integer this,integer index,integer element returns nothing call SaveInteger(s__HashRecyler_ht, this, index, element) endfunction function s__IntArrayList_reverseInner takes integer this,integer first,integer last returns nothing if first < last then set s__IntArrayList_other=s__IntArrayList__getindex(this,first) call s__IntArrayList__setindex(this,first, s__IntArrayList__getindex(this,last)) call s__IntArrayList__setindex(this,last, s__IntArrayList_other) call s__IntArrayList_reverseInner(this,first + 1 , last - 1) endif endfunction function s__IntArrayList_reverse takes integer this returns nothing //call reverseInner(0, .length) set ArrayList__up=0 set ArrayList__down=s__IntArrayList__get_length(this) - 1 loop exitwhen ArrayList__down <= ArrayList__up set s__IntArrayList_other=s__IntArrayList__getindex(this,ArrayList__up) call s__IntArrayList__setindex(this,ArrayList__up, s__IntArrayList__getindex(this,ArrayList__down)) call s__IntArrayList__setindex(this,ArrayList__down, s__IntArrayList_other) set ArrayList__up=ArrayList__up + 1 set ArrayList__down=ArrayList__down - 1 endloop endfunction
Which also explains why using method operators over directly calling the hashtable reaches the OP limit much sooner.
It's your compiler mate, probably your settings. Here's what happens for me.
Compiled to:JASS:scope Test initializer Init private function Init takes nothing returns nothing local IntArrayList list = IntArrayList.create() call list.push(0xF) call list.push(0xFF) set list[0] = list.last() set list[list.length - 1] = list.first() endfunction endscope
Just to clarify, I used your lib without any changes.JASS://=========================================================================== // scope Test begins function Test___Init takes nothing returns nothing local integer list= (s__HashRecyler_alloc()) // INLINED!! call s__IntArrayList_push(list,0xF) call s__IntArrayList_push(list,0xFF) call SaveInteger(s__HashRecyler_ht, (list), (0), ( s__IntArrayList_last(list))) // INLINED!! call SaveInteger(s__HashRecyler_ht, (list), ((LoadInteger(s__HashRecyler_ht, (list), ArrayList___SIZE_INDEX)) - 1), ( (LoadInteger(s__HashRecyler_ht, (list), 0)))) // INLINED!! endfunction // scope Test ends