Skip to content

Commit 4d3f00c

Browse files
deoptimize for old gcc
1 parent 606d84a commit 4d3f00c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

modules/display_format/src/cpp/FormatEngineeringNotation.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <fmt/printf.h>
2828
#include <fmt/format.h>
2929
#include <fmt/xchar.h>
30-
#include <type_traits>
3130
#include "FormatEngineeringNotation.hpp"
3231
#include "IEEEFP.hpp"
3332
//=============================================================================
@@ -114,7 +113,7 @@ formatLongEng(single number, bool trim)
114113
//=============================================================================
115114
template <class T>
116115
std::wstring
117-
formatComplexLongEng(T realPart, T imagPart, bool trim)
116+
formatComplexLongEng(T realPart, T imagPart, bool trim, size_t nbMaxBlanks)
118117
{
119118
std::wstring result;
120119
result.append(formatLongEng(realPart, trim));
@@ -123,32 +122,29 @@ formatComplexLongEng(T realPart, T imagPart, bool trim)
123122
} else {
124123
result.append(L" +");
125124
}
125+
std::wstring imgStr = formatLongEng((T)fabs(imagPart), false);
126126
if (std::isfinite(imagPart)) {
127-
std::wstring imgStr = formatLongEng(fabs(imagPart), false);
128-
size_t nbMaxBlanks = std::is_same<T, float>::value ? 2 : 3;
129127
for (size_t k = 0; k < nbMaxBlanks; ++k) {
130128
if (imgStr[0] == L' ') {
131129
imgStr.erase(0, 1);
132130
}
133131
}
134-
result.append(imgStr);
135-
} else {
136-
result.append(formatLongEng(fabs(imagPart), false));
137132
}
133+
result.append(imgStr);
138134
result.append(L"i");
139135
return result;
140136
}
141137
//=============================================================================
142138
std::wstring
143139
formatComplexLongEng(double realPart, double imagPart, bool trim)
144140
{
145-
return formatComplexLongEng<double>(realPart, imagPart, trim);
141+
return formatComplexLongEng<double>((double)realPart, (double)imagPart, trim, 3);
146142
}
147143
//=============================================================================
148144
std::wstring
149145
formatComplexLongEng(single realPart, single imagPart, bool trim)
150146
{
151-
return formatComplexLongEng<single>(realPart, imagPart, trim);
147+
return formatComplexLongEng<single>((single)realPart, (single)imagPart, trim, 2);
152148
}
153149
//=============================================================================
154150
template <class T>

0 commit comments

Comments
 (0)