From cf73d1efc91039e8533ca4d9a092cdbe9b1b11a4 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 3 May 2017 17:04:27 +0200 Subject: [PATCH] optimize 'text' field in resourcestore instead of doing a lot of string comparisons, we first check the type with the most objects (vms/cts) via number operation and in all other cases, we can simply use the type as property index Signed-off-by: Dominik Csapak --- www/manager6/data/ResourceStore.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/www/manager6/data/ResourceStore.js b/www/manager6/data/ResourceStore.js index e8979804..d17cffc0 100644 --- a/www/manager6/data/ResourceStore.js +++ b/www/manager6/data/ResourceStore.js @@ -69,20 +69,18 @@ Ext.define('PVE.data.ResourceStore', { return value; } - if (info.type === 'node') { - text = info.node; - } else if (info.type === 'pool') { - text = info.pool; - } else if (info.type === 'storage') { - text = info.storage + ' (' + info.node + ')'; - } else if (info.type === 'qemu' || info.type === 'lxc') { + if (Ext.isNumeric(info.vmid) && info.vmid > 0) { text = String(info.vmid); if (info.name) { text += " (" + info.name + ')'; } - } else { - text = info.id; + } else { // node, pool, storage + text = info[info.type] || info.id; + if (info.node && info.type !== 'node') { + text += " (" + info.node + ")"; + } } + return text; } },