Improve performance.

Read all the input before drawing anything on the screen.
This commit is contained in:
ArthurSonzogni 2020-06-01 15:57:18 +02:00 committed by Arthur Sonzogni
parent 0b6fd0c895
commit 3490d56662

View File

@ -272,10 +272,12 @@ void ScreenInteractive::Loop(Component* component) {
// The main loop.
while (!quit_) {
std::cout << reset_cursor_position << ResetPosition();
Draw(component);
std::cout << ToString() << set_cursor_position << std::flush;
Clear();
if (!event_receiver_->HasPending()) {
std::cout << reset_cursor_position << ResetPosition();
Draw(component);
std::cout << ToString() << set_cursor_position << std::flush;
Clear();
}
Event event;
if (event_receiver_->Receive(&event))
component->OnEvent(event);