Skip to content

Conversation

@dsabanin
Copy link

@dsabanin dsabanin commented Dec 4, 2018

On every re-render, update() method was calling this.append(list), that kept adding the rows widgets to the MainPanel over and over again, without ever cleaning up.

You could see the performance degradation when moving back and forth through the log list – the more you moved, the slower it became, to the point of unusability.

Cleaning up the list of children of MainPanel before re-adding the updated rows fixed the issue.

On every re-render, ```update()``` method was calling ```this.append(list)```, that kept adding the widget to the MainPanel over and over again, without ever cleaning up. 

You could see it when moving back and forth through the log list, the more you moved, the slower it became.
Cleaning up the list of children of MainPanel before re-adding the updated rows fixed the issue.
@JakeH
Copy link

JakeH commented Dec 30, 2018

Very nice.

To add to your solution: Creating a new element each time is also a bit wasteful. Would be better to just use the built-in setContent method of the existing element and just omit the call to remove completely.

const [existing] = this.children.filter(o => o.type === 'element');
const list = existing || blessed.element({ tags: true });
list.setContent(content);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants