Mark some limits as constexpr
gcc doesn't need it and computes during compile regardless, but experimenting in godbolt, both clang and MSVC actually do need it or else it's partially computed at runtime
This commit is contained in:
parent
ac7cbcce61
commit
ca7840334c
|
@ -242,7 +242,7 @@ std::map<wxString, wxString> ALTIUM_PARSER::ReadProperties()
|
||||||
|
|
||||||
int32_t ALTIUM_PARSER::ConvertToKicadUnit( const double aValue )
|
int32_t ALTIUM_PARSER::ConvertToKicadUnit( const double aValue )
|
||||||
{
|
{
|
||||||
const double int_limit = ( std::numeric_limits<int>::max() - 1 ) / 2.54;
|
constexpr double int_limit = ( std::numeric_limits<int>::max() - 1 ) / 2.54;
|
||||||
|
|
||||||
int32_t iu = KiROUND( Clamp<double>( -int_limit, aValue, int_limit ) * 2.54 );
|
int32_t iu = KiROUND( Clamp<double>( -int_limit, aValue, int_limit ) * 2.54 );
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,7 @@ int SCH_SEXPR_PARSER::parseInternalUnits()
|
||||||
// Schematic internal units are represented as integers. Any values that are
|
// Schematic internal units are represented as integers. Any values that are
|
||||||
// larger or smaller than the schematic units represent undefined behavior for
|
// larger or smaller than the schematic units represent undefined behavior for
|
||||||
// the system. Limit values to the largest that can be displayed on the screen.
|
// the system. Limit values to the largest that can be displayed on the screen.
|
||||||
double int_limit = std::numeric_limits<int>::max() * 0.7071; // 0.7071 = roughly 1/sqrt(2)
|
constexpr double int_limit = std::numeric_limits<int>::max() * 0.7071; // 0.7071 = roughly 1/sqrt(2)
|
||||||
|
|
||||||
return KiROUND( Clamp<double>( -int_limit, retval, int_limit ) );
|
return KiROUND( Clamp<double>( -int_limit, retval, int_limit ) );
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ int SCH_SEXPR_PARSER::parseInternalUnits( const char* aExpected )
|
||||||
{
|
{
|
||||||
auto retval = parseDouble( aExpected ) * IU_PER_MM;
|
auto retval = parseDouble( aExpected ) * IU_PER_MM;
|
||||||
|
|
||||||
double int_limit = std::numeric_limits<int>::max() * 0.7071;
|
constexpr double int_limit = std::numeric_limits<int>::max() * 0.7071;
|
||||||
|
|
||||||
return KiROUND( Clamp<double>( -int_limit, retval, int_limit ) );
|
return KiROUND( Clamp<double>( -int_limit, retval, int_limit ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,8 @@ int PCB_PARSER::parseBoardUnits()
|
||||||
// larger or smaller than those board units represent undefined behavior for
|
// larger or smaller than those board units represent undefined behavior for
|
||||||
// the system. We limit values to the largest that is visible on the screen
|
// the system. We limit values to the largest that is visible on the screen
|
||||||
// This is the diagonal distance of the full screen ~1.5m
|
// This is the diagonal distance of the full screen ~1.5m
|
||||||
double int_limit = std::numeric_limits<int>::max() * 0.7071; // 0.7071 = roughly 1/sqrt(2)
|
constexpr double int_limit =
|
||||||
|
std::numeric_limits<int>::max() * 0.7071; // 0.7071 = roughly 1/sqrt(2)
|
||||||
return KiROUND( Clamp<double>( -int_limit, retval, int_limit ) );
|
return KiROUND( Clamp<double>( -int_limit, retval, int_limit ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +223,7 @@ int PCB_PARSER::parseBoardUnits( const char* aExpected )
|
||||||
// N.B. we currently represent board units as integers. Any values that are
|
// N.B. we currently represent board units as integers. Any values that are
|
||||||
// larger or smaller than those board units represent undefined behavior for
|
// larger or smaller than those board units represent undefined behavior for
|
||||||
// the system. We limit values to the largest that is visible on the screen
|
// the system. We limit values to the largest that is visible on the screen
|
||||||
double int_limit = std::numeric_limits<int>::max() * 0.7071;
|
constexpr double int_limit = std::numeric_limits<int>::max() * 0.7071;
|
||||||
|
|
||||||
// Use here #KiROUND, not EKIROUND (see comments about them) when having a function as
|
// Use here #KiROUND, not EKIROUND (see comments about them) when having a function as
|
||||||
// argument, because it will be called twice with #KIROUND.
|
// argument, because it will be called twice with #KIROUND.
|
||||||
|
|
Loading…
Reference in New Issue