From b3fb0187f9c02cb98d98c41c076036ee2b528455 Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 5 Aug 2018 13:11:28 -0300 Subject: (perf) Cache scrollItemsLength --- ui/form/ListScrollForm.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/form/ListScrollForm.js b/ui/form/ListScrollForm.js index 300fed4..3f16416 100644 --- a/ui/form/ListScrollForm.js +++ b/ui/form/ListScrollForm.js @@ -62,6 +62,8 @@ module.exports = class ListScrollForm extends Form { item.visible = false } } + + delete this._scrollItemsLength } keyPressed(keyBuf) { @@ -151,8 +153,12 @@ module.exports = class ListScrollForm extends Form { } getScrollItemsLength() { - const lastInput = this.inputs[this.inputs.length - 1] - return this.getScrollPositionOfElementAtEndOfView(lastInput) + if (typeof this._scrollItemsLength === 'undefined') { + const lastInput = this.inputs[this.inputs.length - 1] + this._scrollItemsLength = this.getScrollPositionOfElementAtEndOfView(lastInput) + } + + return this._scrollItemsLength } getItemPos(item) { -- cgit 1.3.0-6-gf8a5