mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-31 07:00:26 +00:00
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.
17 lines
436 B
TypeScript
17 lines
436 B
TypeScript
/*
|
|
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;
|
|
}
|