From: Michael Gernoth Date: Sat, 21 May 2011 16:32:29 +0000 (+0200) Subject: performance improvements X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/commitdiff_plain/e75481cd57c16f5441403e52340d09332ab57c8a performance improvements --- diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java b/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java index 2771ef2..1c14e2c 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java @@ -21,6 +21,11 @@ public class MS2Debounce extends Activity { private DebounceModuleHelper module; + // Calling these is expensive, so cache the result... + private boolean loaded; + private boolean safe_to_load; + private int debounce_delay; + public MS2Debounce() { super(); @@ -42,7 +47,7 @@ public class MS2Debounce extends Activity module.setSavedDelay(Integer.parseInt(delay.toString())); Button reload = (Button)findViewById(R.id.reload); - if (module.isLoaded() && module.getSavedDelay() != module.getDelay()) { + if (loaded && module.getSavedDelay() != debounce_delay) { reload.setEnabled(true); } else { reload.setEnabled(false); @@ -66,9 +71,9 @@ public class MS2Debounce extends Activity disableUI(); // Calling these is expensive, so cache the result... - boolean loaded = module.isLoaded(); - boolean safe_to_load = module.is_safe_to_load(); - int debounce_delay = module.getDelay(); + loaded = module.isLoaded(); + safe_to_load = module.is_safe_to_load(); + debounce_delay = module.getDelay(); TextView text = (TextView)findViewById(R.id.text); text.setText("Current status:\n\nModule loaded: " + loaded + "\ndebounce_delay: " + debounce_delay + "ms\nsafe_to_load: " + safe_to_load);