Prefer Clamp() to std::min( std::max() ).

(cherry picked from commit d545216432)
This commit is contained in:
Jeff Young 2023-03-03 18:25:25 +00:00
parent 1bb6b7acdd
commit e51d43568e
2 changed files with 6 additions and 6 deletions

View File

@ -880,9 +880,9 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent )
int maxWidth = defaultDlgSize.x / 3; int maxWidth = defaultDlgSize.x / 3;
if( col == m_grid->GetNumberCols() - 1 ) if( col == m_grid->GetNumberCols() - 1 )
m_grid->SetColSize( col, std::min( std::max( 50, textWidth ), maxWidth ) ); m_grid->SetColSize( col, Clamp( 50, textWidth, maxWidth ) );
else else
m_grid->SetColSize( col, std::min( std::max( 100, textWidth ), maxWidth ) ); m_grid->SetColSize( col, Clamp( 100, textWidth, maxWidth ) );
} }
} }
} }

View File

@ -104,8 +104,8 @@ public:
CastingType minI = static_cast<CastingType>( std::numeric_limits<int>::min() ); CastingType minI = static_cast<CastingType>( std::numeric_limits<int>::min() );
CastingType maxI = static_cast<CastingType>( std::numeric_limits<int>::max() ); CastingType maxI = static_cast<CastingType>( std::numeric_limits<int>::max() );
x = static_cast<int>( std::max( minI, std::min( aVec.x, maxI ) ) ); x = static_cast<int>( Clamp( minI, aVec.x, maxI ) );
y = static_cast<int>( std::max( minI, std::min( aVec.y, maxI ) ) ); y = static_cast<int>( Clamp( minI, aVec.y, maxI ) );
} }
else else
{ {
@ -130,8 +130,8 @@ public:
T minI = static_cast<T>( std::numeric_limits<int>::min() ); T minI = static_cast<T>( std::numeric_limits<int>::min() );
T maxI = static_cast<T>( std::numeric_limits<int>::max() ); T maxI = static_cast<T>( std::numeric_limits<int>::max() );
return VECTOR2<int>( static_cast<int>( std::max( minI, std::min( x, maxI ) ) ), return VECTOR2<int>( static_cast<int>( Clamp( minI, x, maxI ) ),
static_cast<int>( std::max( minI, std::min( y, maxI ) ) ) ); static_cast<int>( Clamp( minI, y, maxI ) ) );
} }
else else
{ {