Skip to content

Commit

Permalink
Add fast path for TextColor equal check
Browse files Browse the repository at this point in the history
  • Loading branch information
skyline75489 committed Jul 6, 2021
1 parent d3b9a78 commit 0b6b525
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/buffer/out/TextColor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ void TextColor::SetIndex(const BYTE index, const bool isIndex256) noexcept
{
_meta = isIndex256 ? ColorType::IsIndex256 : ColorType::IsIndex16;
_index = index;
_green = 0;
_blue = 0;
}

// Method Description:
Expand All @@ -118,6 +120,9 @@ void TextColor::SetIndex(const BYTE index, const bool isIndex256) noexcept
void TextColor::SetDefault() noexcept
{
_meta = ColorType::IsDefault;
_red = 0;
_green = 0;
_blue = 0;
}

// Method Description:
Expand Down
6 changes: 6 additions & 0 deletions src/buffer/out/TextColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ struct TextColor

bool constexpr operator==(const TextColor& a, const TextColor& b) noexcept
{
if (a._meta == ColorType::IsDefault &&
b._meta == ColorType::IsDefault)
{
return true;
}

return a._meta == b._meta &&
a._red == b._red &&
a._green == b._green &&
Expand Down

0 comments on commit 0b6b525

Please sign in to comment.