mirror of
https://github.com/vector-im/element-call.git
synced 2026-02-11 04:27:03 +00:00
Skip some redundant updates to the grid and spotlight
While debugging our layout shift issue I learned that a single change to the sort order of the participants can cause 3 or 4 redundant emissions of the same items in the same order. Since each of these would cause React to re-render the grid, skipping these spurious emissions seems like an easy performance win.
This commit is contained in:
16
src/utils/array.ts
Normal file
16
src/utils/array.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Determine whether two arrays are equal by shallow comparison.
|
||||
*/
|
||||
export function shallowEquals<A>(first: A[], second: A[]): boolean {
|
||||
if (first.length !== second.length) return false;
|
||||
for (let i = 0; i < first.length; i++)
|
||||
if (first[i] !== second[i]) return false;
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user