[pve-devel] [PATCH manager 2/4] optimize 'text' field in resourcestore

Dominik Csapak d.csapak at proxmox.com
Wed May 3 17:04:27 CEST 2017


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 <d.csapak at proxmox.com>
---
 www/manager6/data/ResourceStore.js | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/www/manager6/data/ResourceStore.js b/www/manager6/data/ResourceStore.js
index 8770d152..93caa6c8 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;
+			text = info[info.type] || info.id;
+			if (info.node && info.type !== 'node') {
+			    text += " (" + info.node + ")";
+			}
 		    }
+
 		    return text;
 		}
 	    },
-- 
2.11.0





More information about the pve-devel mailing list