Skip to content

Commit 9452539

Browse files
jjuhltexus
authored andcommitted
Don't nest conditional operators
It makes the code harder to read and the compiler will optimize out the intermediate temporary variable anyway.
1 parent 1a6b3b3 commit 9452539

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/Widgets/ListView.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,7 +2928,8 @@ namespace tgui
29282928

29292929
states.transform.translate({0, (totalItemHeight * firstItem) + m_itemHeight - static_cast<float>(m_verticalScrollbar->getValue())});
29302930

2931-
const Color& gridLineColor = m_gridLinesColorCached.isSet() ? m_gridLinesColorCached : (m_separatorColorCached.isSet() ? m_separatorColorCached : m_borderColorCached);
2931+
const Color& separatorColor = m_separatorColorCached.isSet() ? m_separatorColorCached : m_borderColorCached;
2932+
const Color& gridLineColor = m_gridLinesColorCached.isSet() ? m_gridLinesColorCached : separatorColor;
29322933
for (std::size_t i = firstItem; i <= lastItem; ++i)
29332934
{
29342935
target.drawFilledRect(states, {availableWidth, static_cast<float>(m_gridLinesWidth)}, Color::applyOpacity(gridLineColor, m_opacityCached));
@@ -3027,7 +3028,8 @@ namespace tgui
30273028
{
30283029
if (m_showVerticalGridLines && (m_gridLinesWidth > 0))
30293030
{
3030-
const Color& gridLineColor = m_gridLinesColorCached.isSet() ? m_gridLinesColorCached : (m_separatorColorCached.isSet() ? m_separatorColorCached : m_borderColorCached);
3031+
const Color& separatorColor = m_separatorColorCached.isSet() ? m_separatorColorCached : m_borderColorCached;
3032+
const Color& gridLineColor = m_gridLinesColorCached.isSet() ? m_gridLinesColorCached : separatorColor;
30313033
if (m_gridLinesWidth == separatorWidth)
30323034
target.drawFilledRect(states, {static_cast<float>(m_gridLinesWidth), innerHeight - totalHeaderHeight}, Color::applyOpacity(gridLineColor, m_opacityCached));
30333035
else

0 commit comments

Comments
 (0)