Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
pills: Optimize removePill function.
ecxtacy6af748fa774f
diff --git a/web/src/input_pill.ts b/web/src/input_pill.tsindex 5186dc52e26..212a5b64b16 100644--- a/web/src/input_pill.ts+++ b/web/src/input_pill.ts@@ -222,14 +222,9 @@ export function create<T>(opts: InputPillCreateOptions<T>): InputPillContainer<T// this would generally be used for DOM-provoked actions, such as a user// clicking on a pill to remove it.removePill(element: HTMLElement) {- let idx: number | undefined;- for (let x = 0; x < store.pills.length; x += 1) {- if (store.pills[x].$element[0] === element) {- idx = x;- }- }+ const idx = store.pills.findIndex((pill) => pill.$element[0] === element);- if (idx !== undefined) {+ if (idx !== -1) {store.pills[idx].$element.remove();const pill = store.pills.splice(idx, 1);if (store.onPillRemove !== undefined) {