mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 18:59:59 +08:00
Avoid making new allocation to clear the screen. (#420)
Previously, a new 2D vector was allocated for every new frame. This caused a lot of temporary allocation to be made. This patch modify "Screen::Clear" so that it do make a new allocation, but clear the existing one instead. Bug:https://github.com/ArthurSonzogni/FTXUI/issues/290#issuecomment-1153327251
This commit is contained in:
parent
925a7578d4
commit
81e086788d
@ -487,8 +487,11 @@ std::string Screen::ResetPosition(bool clear) const {
|
|||||||
|
|
||||||
/// @brief Clear all the pixel from the screen.
|
/// @brief Clear all the pixel from the screen.
|
||||||
void Screen::Clear() {
|
void Screen::Clear() {
|
||||||
pixels_ = std::vector<std::vector<Pixel>>(dimy_,
|
for (auto& line : pixels_) {
|
||||||
std::vector<Pixel>(dimx_, Pixel()));
|
for (auto& cell : line) {
|
||||||
|
cell = Pixel();
|
||||||
|
}
|
||||||
|
}
|
||||||
cursor_.x = dimx_ - 1;
|
cursor_.x = dimx_ - 1;
|
||||||
cursor_.y = dimy_ - 1;
|
cursor_.y = dimy_ - 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user