From b700da547e1340d5641891162a47268d88e8c6d7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 23 Apr 2020 02:39:37 -0400 Subject: [PATCH] CGuiTextSupport: Invert conditionals where applicable Unindents code and allows for easier placement of breakpoints when the conditions are equal to the early exit path. --- Runtime/GuiSys/CGuiTextSupport.cpp | 64 ++++++++++++++++++------------ 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/Runtime/GuiSys/CGuiTextSupport.cpp b/Runtime/GuiSys/CGuiTextSupport.cpp index 0f4021053..9a62ed6c0 100644 --- a/Runtime/GuiSys/CGuiTextSupport.cpp +++ b/Runtime/GuiSys/CGuiTextSupport.cpp @@ -230,17 +230,21 @@ void CGuiTextSupport::Render() { void CGuiTextSupport::SetGeometryColor(const zeus::CColor& col) { x2c_geometryColor = col; } void CGuiTextSupport::SetOutlineColor(const zeus::CColor& col) { - if (col != x28_outlineColor) { - ClearRenderBuffer(); - x28_outlineColor = col; + if (col == x28_outlineColor) { + return; } + + ClearRenderBuffer(); + x28_outlineColor = col; } void CGuiTextSupport::SetFontColor(const zeus::CColor& col) { - if (col != x24_fontColor) { - ClearRenderBuffer(); - x24_fontColor = col; + if (col == x24_fontColor) { + return; } + + ClearRenderBuffer(); + x24_fontColor = col; } void CGuiTextSupport::AddText(std::u16string_view str) { @@ -253,14 +257,16 @@ void CGuiTextSupport::AddText(std::u16string_view str) { } void CGuiTextSupport::SetText(std::u16string_view str, bool multipage) { - if (x0_string != str) { - x40_primStartTimes.clear(); - x3c_curTime = 0.f; - x0_string = str; - ClearRenderBuffer(); - x308_multipageFlag = multipage; - x304_pageCounter = 0; + if (x0_string == str) { + return; } + + x40_primStartTimes.clear(); + x3c_curTime = 0.f; + x0_string = str; + ClearRenderBuffer(); + x308_multipageFlag = multipage; + x304_pageCounter = 0; } void CGuiTextSupport::SetText(std::string_view str, bool multipage) { SetText(hecl::UTF8ToChar16(str), multipage); } @@ -286,24 +292,30 @@ bool CGuiTextSupport::_GetIsTextSupportFinishedLoading() { } void CGuiTextSupport::SetJustification(EJustification j) { - if (j != x14_props.x4_justification) { - x14_props.x4_justification = j; - ClearRenderBuffer(); + if (j == x14_props.x4_justification) { + return; } + + x14_props.x4_justification = j; + ClearRenderBuffer(); } void CGuiTextSupport::SetVerticalJustification(EVerticalJustification j) { - if (j != x14_props.x8_vertJustification) { - x14_props.x8_vertJustification = j; - ClearRenderBuffer(); + if (j == x14_props.x8_vertJustification) { + return; } + + x14_props.x8_vertJustification = j; + ClearRenderBuffer(); } void CGuiTextSupport::SetImageBaseline(bool b) { - if (b != x30_imageBaseline) { - x30_imageBaseline = b; - ClearRenderBuffer(); + if (b == x30_imageBaseline) { + return; } + + x30_imageBaseline = b; + ClearRenderBuffer(); } bool CGuiTextSupport::GetIsTextSupportFinishedLoading() { @@ -312,10 +324,12 @@ bool CGuiTextSupport::GetIsTextSupportFinishedLoading() { } void CGuiTextSupport::SetControlTXTRMap(const std::vector>* txtrMap) { - if (x14_props.xc_txtrMap != txtrMap) { - x14_props.xc_txtrMap = txtrMap; - ClearRenderBuffer(); + if (x14_props.xc_txtrMap == txtrMap) { + return; } + + x14_props.xc_txtrMap = txtrMap; + ClearRenderBuffer(); } int CGuiTextSupport::GetTotalPageCount() {