From c14fa7a1d36c2adf4376a454ed9269b5c6eb8758 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 10 Nov 2023 18:14:26 -0500 Subject: [PATCH] [Perf] reduce some rendezvous --- .../VideoFeed/VideoRowListRowContentTask.bs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs b/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs index 3b8fdc03..0d23dc9e 100644 --- a/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs +++ b/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs @@ -154,15 +154,26 @@ function VideoRowListRowContentTask(input as object) as object end function function RemovePlaceHolderItems(contentNode as object) + childCount = contentNode.getChildCount() + removeIndex = childCount + removeCount = 0 + + index = childCount - 1 isLoading = true - while isLoading and contentNode.getChildCount() > 0 - lastIndex = contentNode.getChildCount() - 1 - child = contentNode.getChild(lastIndex) - isLoading = IsString(child.type) and child.type = "loading" - if isLoading = true - contentNode.removeChildIndex(lastIndex) + while isLoading and index >= 0 + child = contentNode.getChild(index) + isLoading = ValidString(child.type) = "loading" + if not isLoading + exit while end if + removeCount += 1 + removeIndex -= 1 + index -= 1 end while + + if removeCount > 0 + contentNode.removeChildrenIndex(removeCount, removeIndex) + end if end function function HandleFeedLoadErrorDialog(error as object, rowList as object) as void