which is better performance, using a disposable local variable or reusing a global one?
Posted
by
petervaz
on Game Development
See other posts from Game Development
or by petervaz
Published on 2012-11-21T13:45:24Z
Indexed on
2012/11/21
17:16 UTC
Read the original article
Hit count: 212
This is for an android game. Suppose I have a function that is called several times for second and do some calculations involving an arraylist (or any other complex objects for what matter). Which approach would be preffered?
local:
private void doStuff(){
ArrayList<Type> XList = new ArrayList<Type>();
// do stuff with list
}
global:
private ArrayList<Type> XList = new ArrayList<Type>();
private void doStuff(){
XList.clear();
// do stuff with list
}
© Game Development or respective owner