From d5452164329fe1f1a2aaa3dedfae3d8a17d44bc8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 3 Mar 2023 18:25:25 +0000 Subject: [PATCH] Prefer Clamp() to std::min( std::max() ). --- eeschema/dialogs/dialog_symbol_fields_table.cpp | 4 ++-- libs/kimath/include/math/vector2d.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eeschema/dialogs/dialog_symbol_fields_table.cpp b/eeschema/dialogs/dialog_symbol_fields_table.cpp index 978b60b995..9aff640298 100644 --- a/eeschema/dialogs/dialog_symbol_fields_table.cpp +++ b/eeschema/dialogs/dialog_symbol_fields_table.cpp @@ -880,9 +880,9 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent ) int maxWidth = defaultDlgSize.x / 3; 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 - m_grid->SetColSize( col, std::min( std::max( 100, textWidth ), maxWidth ) ); + m_grid->SetColSize( col, Clamp( 100, textWidth, maxWidth ) ); } } } diff --git a/libs/kimath/include/math/vector2d.h b/libs/kimath/include/math/vector2d.h index ec763a9bdf..2e97702807 100644 --- a/libs/kimath/include/math/vector2d.h +++ b/libs/kimath/include/math/vector2d.h @@ -92,8 +92,8 @@ public: CastingType minI = static_cast( std::numeric_limits::min() ); CastingType maxI = static_cast( std::numeric_limits::max() ); - x = static_cast( std::max( minI, std::min( aVec.x, maxI ) ) ); - y = static_cast( std::max( minI, std::min( aVec.y, maxI ) ) ); + x = static_cast( Clamp( minI, aVec.x, maxI ) ); + y = static_cast( Clamp( minI, aVec.y, maxI ) ); } else { @@ -118,8 +118,8 @@ public: T minI = static_cast( std::numeric_limits::min() ); T maxI = static_cast( std::numeric_limits::max() ); - return VECTOR2( static_cast( std::max( minI, std::min( x, maxI ) ) ), - static_cast( std::max( minI, std::min( y, maxI ) ) ) ); + return VECTOR2( static_cast( Clamp( minI, x, maxI ) ), + static_cast( Clamp( minI, y, maxI ) ) ); } else {