aboutsummaryrefslogtreecommitdiffstats
path: root/javascript/ui.js
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2023-05-19 10:06:12 +0000
committerAarni Koskela <akx@iki.fi>2023-05-19 10:06:12 +0000
commit67d4360453e0316b494a43320e2e5df53a93d5ea (patch)
treeb3263e2e08cbaff20adb394bfe36e944c93aab55 /javascript/ui.js
parent563e88dd91c80856697ec4f879de9a0516ebef5b (diff)
downloadstable-diffusion-webui-gfx803-67d4360453e0316b494a43320e2e5df53a93d5ea.tar.gz
stable-diffusion-webui-gfx803-67d4360453e0316b494a43320e2e5df53a93d5ea.tar.bz2
stable-diffusion-webui-gfx803-67d4360453e0316b494a43320e2e5df53a93d5ea.zip
get_tab_index(): use a for loop with early-exit for performance
Diffstat (limited to 'javascript/ui.js')
-rw-r--r--javascript/ui.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/javascript/ui.js b/javascript/ui.js
index f13e7b6c..648a5290 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -100,15 +100,13 @@ function switch_to_extras() {
}
function get_tab_index(tabId) {
- var res = 0;
-
- gradioApp().getElementById(tabId).querySelector('div').querySelectorAll('button').forEach(function(button, i) {
- if (button.className.indexOf('selected') != -1) {
- res = i;
+ let buttons = gradioApp().getElementById(tabId).querySelector('div').querySelectorAll('button');
+ for (let i = 0; i < buttons.length; i++) {
+ if (buttons[i].classList.contains('selected')) {
+ return i;
}
- });
-
- return res;
+ }
+ return 0;
}
function create_tab_index_args(tabId, args) {