Raffaello / sdl2-vga-terminal

SDL2 VGA Terminal
MIT License
6 stars 1 forks source link

[VgaTerminal | _setCharAtCursorPosition ] optimization consideration #165

Open Raffaello opened 4 years ago

Raffaello commented 4 years ago

define an operator to simplify this expression what is compared here is the terminalchar_t not the _terminalChar_t rendered flag in this case is ignored.

probably i would prefer embed the public struct instead of inheriting it.

require a little bit more refactor around the code base.

void VgaTerminal::_setCharAtCursorPosition(const _terminalChar_t& tc) noexcept
{
    std::lock_guard lck(_pGridMutex);
    _pGrid[_getCursorPosition()] = tc;
    _terminalChar_t _tc = _pGrid[_getCursorPosition()];
    // TODO define an operator to simply this expression
    // BODY what is compared here is the terminalchar_t not the _terminalChar_t
    // BODY rendered flag in this case is ignored.
    if (!(_tc.c == tc.c && _tc.col == tc.col && _tc.bgCol == tc.bgCol)) {
        _pGrid[_getCursorPosition()] = tc;
    }
}

https://github.com/Raffaello/sdl2-vga-terminal/pull/158/commits/7cfb0d2778a2ef0c42a77deb6a0d84ab2dbc3368#diff-def179fd004d0dc0eb36f412bf425652R576-R586


this bit might require a major refactor of the structs and where to organize in the code, might be worth extract from the class...

it could be coupled with other tickets dealing with structs and code re-organization