From 341c4249412a04b863c18c4e3bea33d314595e1c Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Sat, 9 Aug 2025 19:32:44 +0200 Subject: [PATCH] Cache tag controller lists for registry --- src/controller-registry.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controller-registry.js b/src/controller-registry.js index 7b44060..2c45fdf 100644 --- a/src/controller-registry.js +++ b/src/controller-registry.js @@ -126,8 +126,15 @@ export class ControllerRegistry { return this.#defined.get(name) } + #listMap = new WeakMap() list(element) { - return new ControllerList(element, this.#attribute) + if (this.#listMap.has(element)) { + return this.#listMap.get(element) + } else { + const list = new ControllerList(element, this.#attribute) + this.#listMap.set(element, list) + return list + } } getName(controller) {