From 82f90c473400c2ce643644b50c34dc87c8ab0914 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 23 Jul 2020 22:31:52 -0600 Subject: [PATCH] Do the faster length change check first ... because it's faster. Also we don't need to diff the array here. --- src/components/views/rooms/RoomSublist.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/views/rooms/RoomSublist.tsx b/src/components/views/rooms/RoomSublist.tsx index a15a6c9cde..6438455a0a 100644 --- a/src/components/views/rooms/RoomSublist.tsx +++ b/src/components/views/rooms/RoomSublist.tsx @@ -47,7 +47,7 @@ import { Direction } from "re-resizable/lib/resizer"; import { polyfillTouchEvent } from "../../../@types/polyfill"; import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore"; import RoomListLayoutStore from "../../../stores/room-list/RoomListLayoutStore"; -import { arrayHasDiff, arrayHasOrderChange } from "../../../utils/arrays"; +import { arrayHasOrderChange } from "../../../utils/arrays"; import { objectExcluding, objectHasValueChange } from "../../../utils/objects"; const SHOW_N_BUTTON_HEIGHT = 28; // As defined by CSS @@ -202,6 +202,11 @@ export default class RoomSublist extends React.Component { return true; } + // Quickly double check we're not about to break something due to the number of rooms changing. + if (this.state.rooms.length !== nextState.rooms.length) { + return true; + } + // Finally, determine if the room update (as presumably that's all that's left) is within // our visible range. If it is, then do a render. If the update is outside our visible range // then we can skip the update. @@ -215,11 +220,6 @@ export default class RoomSublist extends React.Component { return true; } - // Quickly double check we're not about to break something due to the number of rooms changing. - if (arrayHasDiff(this.state.rooms, nextState.rooms)) { - return true; - } - // Finally, nothing happened so no-op the update return false; }