Map Enumerators: Proposed change

Monkey Forums/Monkey Bug Reports/Map Enumerators: Proposed change

AdamRedwoods(Posted 2014) [#1]
Map iteration is slow when using Eachin and Values(). Please consider making NextNode,PrevNode,FirstNode,LastNode, and Value() public instead of private.

Example:

the above changes (3rd timer) , when public, is almost 50% faster on Android (v4.1), and uses less class constructor calls.
my output:
I/[Monkey]( 4944): k=100100
I/[Monkey]( 4944): 240
I/[Monkey]( 4944): k=100100
I/[Monkey]( 4944): 131
I/[Monkey]( 4944): k=100100
I/[Monkey]( 4944): 61



marksibly(Posted 2014) [#2]
Compiles here anyway! Looks like some bug has crept into public/private...

It appears that Value, NextNode and PrevNode are already public, so I don't see any particular reason why FirstNode and LastNode can't also be public.

That said, while using NextNode like this will improve the speed of a virtually empty loop, it'll have much less impact on code that actually does something, although it will make it harder to read.


AdamRedwoods(Posted 2014) [#3]
it'll have much less impact on code that actually does something,

i noticed this on Android/Java, when you have a loop over the Map loop (lots of constructor calling). that's why i posted the example to show specifically how this is influential. seems to make a difference in collision detection.