]> git.zerfleddert.de Git - ms2-fixes/commitdiff
performance improvements
authorMichael Gernoth <michael@gernoth.net>
Sat, 21 May 2011 16:32:29 +0000 (18:32 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sat, 21 May 2011 16:32:29 +0000 (18:32 +0200)
MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java

index 2771ef2a11669ed6149497e2975cb2910cd56d78..1c14e2c32d7e482f136684b6f21095d64d7993eb 100644 (file)
@@ -21,6 +21,11 @@ public class MS2Debounce extends Activity
 {
        private DebounceModuleHelper module;
 
 {
        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();
        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);
                                        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);
                                                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...
                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);
 
                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);
Impressum, Datenschutz