mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
Explicit std::min/max template usage
This is unfortunately required in several cases: - Sometimes when we use either float and double (this should be changed) - Because KDCoordinate is not an int, so any arithmemtic promotes it to an int - Because we mix pointer differences and ints
This commit is contained in:
@@ -129,8 +129,8 @@ float GraphController::interestingXHalfRange() const {
|
||||
}
|
||||
// Compute the combined range of the functions
|
||||
assert(f->plotType() == ContinuousFunction::PlotType::Cartesian); // So that tMin tMax represents xMin xMax
|
||||
tMin = std::min(tMin, f->tMin());
|
||||
tMax = std::max(tMax, f->tMax());
|
||||
tMin = std::min<double>(tMin, f->tMin());
|
||||
tMax = std::max<double>(tMax, f->tMax());
|
||||
}
|
||||
constexpr float rangeMultiplicator = 1.6f;
|
||||
if (characteristicRange > 0.0f ) {
|
||||
|
||||
@@ -78,7 +78,7 @@ double ChiSquaredDistribution::cumulativeDistributiveInverseForProbability(doubl
|
||||
2.0 * *probability * std::exp(std::lgamma(ceilKOver2)) / (exp(-kOver2Minus1) * std::pow(kOver2Minus1, kOver2Minus1)) :
|
||||
30.0; // Ad hoc value
|
||||
xmax = std::isnan(xmax) ? 1000000000.0 : xmax;
|
||||
return cumulativeDistributiveInverseForProbabilityUsingIncreasingFunctionRoot(probability, FLT_EPSILON, std::max(xMax(), xmax));
|
||||
return cumulativeDistributiveInverseForProbabilityUsingIncreasingFunctionRoot(probability, FLT_EPSILON, std::max<double>(xMax(), xmax));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ double FisherDistribution::cumulativeDistributiveInverseForProbability(double *
|
||||
if (*probability < DBL_EPSILON) {
|
||||
return 0.0;
|
||||
}
|
||||
return cumulativeDistributiveInverseForProbabilityUsingIncreasingFunctionRoot(probability, DBL_EPSILON, std::max(xMax(), 100.0)); // Ad-hoc value;
|
||||
return cumulativeDistributiveInverseForProbabilityUsingIncreasingFunctionRoot(probability, DBL_EPSILON, std::max<double>(xMax(), 100.0)); // Ad-hoc value;
|
||||
}
|
||||
|
||||
float FisherDistribution::mode() const {
|
||||
|
||||
@@ -162,7 +162,7 @@ void GraphController::reloadBannerView() {
|
||||
}
|
||||
if (!coefficientsAreDefined) {
|
||||
// Force the "Data not suitable" message to be on the next line
|
||||
int numberOfCharToCompleteLine = std::max(Ion::Display::Width / BannerView::Font()->glyphSize().width() - strlen(I18n::translate(formula)), 0);
|
||||
int numberOfCharToCompleteLine = std::max<int>(Ion::Display::Width / BannerView::Font()->glyphSize().width() - strlen(I18n::translate(formula)), 0);
|
||||
numberOfChar = 0;
|
||||
// Padding
|
||||
Shared::TextHelpers::PadWithSpaces(buffer, bufferSize, &numberOfChar, numberOfCharToCompleteLine - 1);
|
||||
@@ -387,8 +387,8 @@ InteractiveCurveViewRangeDelegate::Range GraphController::computeYRange(Interact
|
||||
for (int series = 0; series < Store::k_numberOfSeries; series++) {
|
||||
for (int k = 0; k < m_store->numberOfPairsOfSeries(series); k++) {
|
||||
if (m_store->xMin() <= m_store->get(series, 0, k) && m_store->get(series, 0, k) <= m_store->xMax()) {
|
||||
minY = std::min(minY, m_store->get(series, 1, k));
|
||||
maxY = std::max(maxY, m_store->get(series, 1, k));
|
||||
minY = std::min<float>(minY, m_store->get(series, 1, k));
|
||||
maxY = std::max<float>(maxY, m_store->get(series, 1, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ void Store::resetMemoization() {
|
||||
float Store::maxValueOfColumn(int series, int i) const {
|
||||
float maxColumn = -FLT_MAX;
|
||||
for (int k = 0; k < numberOfPairsOfSeries(series); k++) {
|
||||
maxColumn = std::max(maxColumn, m_data[series][i][k]);
|
||||
maxColumn = std::max<float>(maxColumn, m_data[series][i][k]);
|
||||
}
|
||||
return maxColumn;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ float Store::maxValueOfColumn(int series, int i) const {
|
||||
float Store::minValueOfColumn(int series, int i) const {
|
||||
float minColumn = FLT_MAX;
|
||||
for (int k = 0; k < numberOfPairsOfSeries(series); k++) {
|
||||
minColumn = std::min(minColumn, m_data[series][i][k]);
|
||||
minColumn = std::min<float>(minColumn, m_data[series][i][k]);
|
||||
}
|
||||
return minColumn;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ float GraphController::interestingXHalfRange() const {
|
||||
Sequence * s = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
|
||||
int firstInterestingIndex = s->initialRank();
|
||||
nmin = std::min(nmin, firstInterestingIndex);
|
||||
nmax = std::max(nmax, firstInterestingIndex + standardRange);
|
||||
nmax = std::max(nmax, firstInterestingIndex + static_cast<int>(standardRange));
|
||||
}
|
||||
assert(nmax - nmin >= standardRange);
|
||||
return nmax - nmin;
|
||||
|
||||
@@ -54,7 +54,7 @@ KDCoordinate ListController::expressionRowHeight(int j) {
|
||||
return defaultHeight;
|
||||
}
|
||||
KDCoordinate sequenceHeight = layout.layoutSize().height();
|
||||
return std::max(defaultHeight, sequenceHeight + 2*k_expressionCellVerticalMargin);
|
||||
return std::max<KDCoordinate>(defaultHeight, sequenceHeight + 2*k_expressionCellVerticalMargin);
|
||||
}
|
||||
|
||||
void ListController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
|
||||
|
||||
@@ -144,7 +144,7 @@ void PreferencesController::setPreferenceWithValueIndex(I18n::Message message, i
|
||||
/* In Engineering mode, the number of significant digits cannot be lower
|
||||
* than 3, because we need to be able to display 100 for instance. */
|
||||
// TODO: Add warning about signifiant digits change ?
|
||||
preferences->setNumberOfSignificantDigits(std::max(preferences->numberOfSignificantDigits(), 3));
|
||||
preferences->setNumberOfSignificantDigits(std::max<int>(preferences->numberOfSignificantDigits(), 3));
|
||||
}
|
||||
} else if (message == I18n::Message::EditionMode) {
|
||||
preferences->setEditionMode((Preferences::EditionMode)valueIndex);
|
||||
|
||||
@@ -51,7 +51,7 @@ void SelectableViewWithMessages::layoutSubviews(bool force) {
|
||||
|
||||
// Layout the text
|
||||
KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height();
|
||||
KDCoordinate defOrigin = std::max(bounds().height() - Metric::CommonBottomMargin - m_numberOfMessages*textHeight, tableHeight);
|
||||
KDCoordinate defOrigin = std::max<KDCoordinate>(bounds().height() - Metric::CommonBottomMargin - m_numberOfMessages*textHeight, tableHeight);
|
||||
|
||||
for (int i = 0; i < m_numberOfMessages; i++) {
|
||||
m_messageLines[i].setFrame(KDRect(0, defOrigin, bounds().width(), textHeight), force);
|
||||
|
||||
@@ -310,8 +310,8 @@ Coordinate2D<double> ContinuousFunction::nextIntersectionFrom(double start, doub
|
||||
constexpr int bufferSize = CodePoint::MaxCodePointCharLength + 1;
|
||||
char unknownX[bufferSize];
|
||||
SerializationHelper::CodePoint(unknownX, bufferSize, UCodePointUnknown);
|
||||
double domainMin = std::max(tMin(), eDomainMin);
|
||||
double domainMax = std::min(tMax(), eDomainMax);
|
||||
double domainMin = std::max<double>(tMin(), eDomainMin);
|
||||
double domainMax = std::min<double>(tMax(), eDomainMax);
|
||||
if (step > 0.0f) {
|
||||
start = std::max(start, domainMin);
|
||||
max = std::min(max, domainMax);
|
||||
@@ -328,19 +328,19 @@ Coordinate2D<double> ContinuousFunction::nextPointOfInterestFrom(double start, d
|
||||
char unknownX[bufferSize];
|
||||
SerializationHelper::CodePoint(unknownX, bufferSize, UCodePointUnknown);
|
||||
if (step > 0.0f) {
|
||||
start = std::max(start, tMin());
|
||||
max = std::min(max, tMax());
|
||||
start = std::max<double>(start, tMin());
|
||||
max = std::min<double>(max, tMax());
|
||||
} else {
|
||||
start = std::min(start, tMax());
|
||||
max = std::max(max, tMin());
|
||||
start = std::min<double>(start, tMax());
|
||||
max = std::max<double>(max, tMin());
|
||||
}
|
||||
return compute(expressionReduced(context), unknownX, start, step, max, context);
|
||||
}
|
||||
|
||||
Poincare::Expression ContinuousFunction::sumBetweenBounds(double start, double end, Poincare::Context * context) const {
|
||||
assert(plotType() == PlotType::Cartesian);
|
||||
start = std::max(start, tMin());
|
||||
end = std::min(end, tMax());
|
||||
start = std::max<double>(start, tMin());
|
||||
end = std::min<double>(end, tMax());
|
||||
return Poincare::Integral::Builder(expressionReduced(context).clone(), Poincare::Symbol::Builder(UCodePointUnknown), Poincare::Float<double>::Builder(start), Poincare::Float<double>::Builder(end)); // Integral takes ownership of args
|
||||
/* TODO: when we approximate integral, we might want to simplify the integral
|
||||
* here. However, we might want to do it once for all x (to avoid lagging in
|
||||
|
||||
@@ -179,7 +179,7 @@ void CurveView::computeLabels(Axis axis) {
|
||||
int labelMaxGlyphLength = labelMaxGlyphLengthSize();
|
||||
if (axis == Axis::Horizontal) {
|
||||
float pixelsPerLabel = std::max(0.0f, ((float)Ion::Display::Width)/((float)axisLabelsCount) - k_labelMargin);
|
||||
labelMaxGlyphLength = std::min(labelMaxGlyphLengthSize(), pixelsPerLabel/k_font->glyphSize().width());
|
||||
labelMaxGlyphLength = std::min<int>(labelMaxGlyphLengthSize(), pixelsPerLabel/k_font->glyphSize().width());
|
||||
}
|
||||
|
||||
if (labelValue < step && labelValue > -step) {
|
||||
|
||||
@@ -88,13 +88,13 @@ InteractiveCurveViewRangeDelegate::Range FunctionGraphController::computeYRange(
|
||||
if (std::isnan(tMin)) {
|
||||
tMin = xMin;
|
||||
} else if (f->shouldClipTRangeToXRange()) {
|
||||
tMin = std::max(tMin, xMin);
|
||||
tMin = std::max<double>(tMin, xMin);
|
||||
}
|
||||
double tMax = f->tMax();
|
||||
if (std::isnan(tMax)) {
|
||||
tMax = xMax;
|
||||
} else if (f->shouldClipTRangeToXRange()) {
|
||||
tMax = std::min(tMax, xMax);
|
||||
tMax = std::min<double>(tMax, xMax);
|
||||
}
|
||||
/* In practice, a step smaller than a pixel's width is needed for sampling
|
||||
* the values of a function. Otherwise some relevant extremal values may be
|
||||
@@ -163,7 +163,7 @@ bool FunctionGraphController::moveCursorVertically(int direction) {
|
||||
double clippedT = m_cursor->t();
|
||||
if (!std::isnan(f->tMin())) {
|
||||
assert(!std::isnan(f->tMax()));
|
||||
clippedT = std::min(f->tMax(), std::max(f->tMin(), clippedT));
|
||||
clippedT = std::min<double>(f->tMax(), std::max<double>(f->tMin(), clippedT));
|
||||
}
|
||||
Poincare::Coordinate2D<double> cursorPosition = f->evaluateXYAtParameter(clippedT, context);
|
||||
m_cursor->moveTo(clippedT, cursorPosition.x1(), cursorPosition.x2());
|
||||
|
||||
@@ -261,7 +261,7 @@ KDCoordinate FunctionListController::maxFunctionNameWidth() {
|
||||
const char * functionName = record.fullName();
|
||||
const char * dotPosition = strchr(functionName, Ion::Storage::k_dotChar);
|
||||
assert(dotPosition != nullptr);
|
||||
maxNameLength = std::max(maxNameLength, dotPosition-functionName);
|
||||
maxNameLength = std::max(maxNameLength, static_cast<int>(dotPosition-functionName));
|
||||
}
|
||||
return nameWidth(maxNameLength + Function::k_parenthesedArgumentCodePointLength);
|
||||
}
|
||||
|
||||
@@ -191,8 +191,8 @@ void HistogramController::preinitXRangeParameters() {
|
||||
float maxValue = -FLT_MAX;
|
||||
for (int i = 0; i < Store::k_numberOfSeries; i ++) {
|
||||
if (!m_store->seriesIsEmpty(i)) {
|
||||
minValue = std::min(minValue, m_store->minValue(i));
|
||||
maxValue = std::max(maxValue, m_store->maxValue(i));
|
||||
minValue = std::min<float>(minValue, m_store->minValue(i));
|
||||
maxValue = std::max<float>(maxValue, m_store->maxValue(i));
|
||||
}
|
||||
}
|
||||
m_store->setXMin(minValue);
|
||||
|
||||
@@ -127,7 +127,7 @@ KDCoordinate VariableBoxController::rowHeight(int index) {
|
||||
if (m_currentPage != Page::RootMenu) {
|
||||
Layout layoutR = expressionLayoutForRecord(recordAtIndex(index), index);
|
||||
if (!layoutR.isUninitialized()) {
|
||||
return std::max(layoutR.layoutSize().height()+k_leafMargin, Metric::ToolboxRowHeight);
|
||||
return std::max<KDCoordinate>(layoutR.layoutSize().height()+k_leafMargin, Metric::ToolboxRowHeight);
|
||||
}
|
||||
}
|
||||
return NestedMenuController::rowHeight(index);
|
||||
|
||||
@@ -64,7 +64,7 @@ KDSize ExpressionView::minimalSizeForOptimalDisplay() const {
|
||||
|
||||
KDPoint ExpressionView::drawingOrigin() const {
|
||||
KDSize expressionSize = m_layout.layoutSize();
|
||||
return KDPoint(m_horizontalMargin + m_horizontalAlignment*(m_frame.width() - 2*m_horizontalMargin - expressionSize.width()), std::max(0, m_verticalAlignment*(m_frame.height() - expressionSize.height())));
|
||||
return KDPoint(m_horizontalMargin + m_horizontalAlignment*(m_frame.width() - 2*m_horizontalMargin - expressionSize.width()), std::max<KDCoordinate>(0, m_verticalAlignment*(m_frame.height() - expressionSize.height())));
|
||||
}
|
||||
|
||||
KDPoint ExpressionView::absoluteDrawingOrigin() const {
|
||||
|
||||
@@ -610,7 +610,7 @@ void LayoutField::scrollToBaselinedRect(KDRect rect, KDCoordinate baseline) {
|
||||
// Show the rect area around its baseline
|
||||
KDCoordinate underBaseline = rect.height() - baseline;
|
||||
KDCoordinate minAroundBaseline = std::min(baseline, underBaseline);
|
||||
minAroundBaseline = std::min(minAroundBaseline, bounds().height() / 2);
|
||||
minAroundBaseline = std::min<KDCoordinate>(minAroundBaseline, bounds().height() / 2);
|
||||
KDRect balancedRect(rect.x(), rect.y() + baseline - minAroundBaseline, rect.width(), 2 * minAroundBaseline);
|
||||
scrollToContentRect(balancedRect, true);
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ void ScrollView::scrollToContentPoint(KDPoint p, bool allowOverscroll) {
|
||||
|
||||
// Handle cases when the size of the view has decreased.
|
||||
setContentOffset(KDPoint(
|
||||
std::min(contentOffset().x(), std::max(minimalSizeForOptimalDisplay().width() - bounds().width(), 0)),
|
||||
std::min(contentOffset().y(), std::max(minimalSizeForOptimalDisplay().height() - bounds().height(), 0))));
|
||||
std::min(contentOffset().x(), std::max<KDCoordinate>(minimalSizeForOptimalDisplay().width() - bounds().width(), KDCoordinate{0})),
|
||||
std::min(contentOffset().y(), std::max<KDCoordinate>(minimalSizeForOptimalDisplay().height() - bounds().height(), 0))));
|
||||
}
|
||||
|
||||
void ScrollView::scrollToContentRect(KDRect rect, bool allowOverscroll) {
|
||||
|
||||
@@ -93,21 +93,21 @@ void TableCell::layoutSubviews(bool force) {
|
||||
KDCoordinate y = k_separatorThickness;
|
||||
if (label) {
|
||||
y += k_verticalMargin;
|
||||
KDCoordinate labelHeight = std::min(labelSize.height(), height - y - k_separatorThickness - k_verticalMargin);
|
||||
KDCoordinate labelHeight = std::min<KDCoordinate>(labelSize.height(), height - y - k_separatorThickness - k_verticalMargin);
|
||||
label->setFrame(KDRect(horizontalMargin, y, width-2*horizontalMargin, labelHeight), force);
|
||||
y += labelHeight + k_verticalMargin;
|
||||
}
|
||||
horizontalMargin = k_separatorThickness + k_horizontalMargin;
|
||||
y = std::max(y, height - k_separatorThickness - withMargin(accessorySize.height(), Metric::TableCellVerticalMargin) - withMargin(subAccessorySize.height(), 0));
|
||||
y = std::max<KDCoordinate>(y, height - k_separatorThickness - withMargin(accessorySize.height(), Metric::TableCellVerticalMargin) - withMargin(subAccessorySize.height(), 0));
|
||||
if (subAccessory) {
|
||||
KDCoordinate subAccessoryHeight = std::min(subAccessorySize.height(), height - y - k_separatorThickness - Metric::TableCellVerticalMargin);
|
||||
KDCoordinate subAccessoryHeight = std::min<KDCoordinate>(subAccessorySize.height(), height - y - k_separatorThickness - Metric::TableCellVerticalMargin);
|
||||
accessory->setFrame(KDRect(horizontalMargin, y, width - 2*horizontalMargin, subAccessoryHeight), force);
|
||||
y += subAccessoryHeight;
|
||||
}
|
||||
horizontalMargin = k_separatorThickness + accessoryMargin();
|
||||
y = std::max(y, height - k_separatorThickness - withMargin(accessorySize.height(), Metric::TableCellVerticalMargin));
|
||||
y = std::max<KDCoordinate>(y, height - k_separatorThickness - withMargin(accessorySize.height(), Metric::TableCellVerticalMargin));
|
||||
if (accessory) {
|
||||
KDCoordinate accessoryHeight = std::min(accessorySize.height(), height - y - k_separatorThickness - Metric::TableCellVerticalMargin);
|
||||
KDCoordinate accessoryHeight = std::min<KDCoordinate>(accessorySize.height(), height - y - k_separatorThickness - Metric::TableCellVerticalMargin);
|
||||
accessory->setFrame(KDRect(horizontalMargin, y, width - 2*horizontalMargin, accessoryHeight), force);
|
||||
}
|
||||
} else {
|
||||
@@ -139,25 +139,25 @@ void TableCell::layoutSubviews(bool force) {
|
||||
KDCoordinate accessoryX = std::max(k_separatorThickness + accessoryMargin(), width - k_separatorThickness - withMargin(accessorySize.width(), accessoryMargin()));
|
||||
if (label) {
|
||||
x = labelX;
|
||||
KDCoordinate labelWidth = std::min(labelSize.width(), width - x - k_separatorThickness - labelMargin());
|
||||
KDCoordinate labelWidth = std::min<KDCoordinate>(labelSize.width(), width - x - k_separatorThickness - labelMargin());
|
||||
if (m_layout == Layout::HorizontalRightOverlap) {
|
||||
labelWidth = std::min(labelWidth, subAccessoryX - x - labelMargin());
|
||||
labelWidth = std::min<KDCoordinate>(labelWidth, subAccessoryX - x - labelMargin());
|
||||
}
|
||||
label->setFrame(KDRect(x, verticalMargin, labelWidth, height-2*verticalMargin), force);
|
||||
x += labelWidth + labelMargin();
|
||||
}
|
||||
if (subAccessory) {
|
||||
x = std::max(x, subAccessoryX);
|
||||
KDCoordinate subAccessoryWidth = std::min(subAccessorySize.width(), width - x - k_separatorThickness - k_horizontalMargin);
|
||||
KDCoordinate subAccessoryWidth = std::min<KDCoordinate>(subAccessorySize.width(), width - x - k_separatorThickness - k_horizontalMargin);
|
||||
if (m_layout == Layout::HorizontalRightOverlap) {
|
||||
subAccessoryWidth = std::min(subAccessoryWidth, accessoryX - x);
|
||||
subAccessoryWidth = std::min<KDCoordinate>(subAccessoryWidth, accessoryX - x);
|
||||
}
|
||||
subAccessory->setFrame(KDRect(x, verticalMargin, subAccessoryWidth, height-2*verticalMargin), force);
|
||||
x += subAccessoryWidth;
|
||||
}
|
||||
if (accessory) {
|
||||
x = std::max(x, accessoryX);
|
||||
KDCoordinate accessoryWidth = std::min(accessorySize.width(), width - x - k_separatorThickness - accessoryMargin());
|
||||
KDCoordinate accessoryWidth = std::min<KDCoordinate>(accessorySize.width(), width - x - k_separatorThickness - accessoryMargin());
|
||||
accessory->setFrame(KDRect(x, verticalMargin, accessoryWidth, height-2*verticalMargin), force);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column,
|
||||
m_font,
|
||||
textColor,
|
||||
backgroundColor,
|
||||
drawSelection ? (selectionStart >= text ? std::min(length, selectionStart - text) : 0) : length
|
||||
drawSelection ? (selectionStart >= text ? std::min<KDCoordinate>(length, selectionStart - text) : 0) : length
|
||||
);
|
||||
if (!drawSelection) {
|
||||
return;
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
};
|
||||
|
||||
constexpr static int k_maxPacketSize = 64;
|
||||
constexpr static int MaxTransferSize = 2048;
|
||||
constexpr static uint16_t MaxTransferSize = 2048;
|
||||
|
||||
constexpr Endpoint0(RequestRecipient * device, RequestRecipient * interface) :
|
||||
m_forceNAK(false),
|
||||
|
||||
@@ -173,7 +173,8 @@ size_t CopyUntilCodePoint(char * dst, size_t dstSize, const char * src, CodePoin
|
||||
codePointPointer = decoder.stringPosition();
|
||||
codePoint = decoder.nextCodePoint();
|
||||
}
|
||||
size_t copySize = std::min(dstSize - 1, codePointPointer - src);
|
||||
assert(codePointPointer >= src);
|
||||
size_t copySize = std::min(dstSize - 1, static_cast<size_t>(codePointPointer - src));
|
||||
assert(UTF8Helper::CodePointIs(src + copySize, 0) || UTF8Helper::CodePointIs(src + copySize, c));
|
||||
memmove(dst, src, copySize);
|
||||
assert(copySize < dstSize);
|
||||
|
||||
@@ -137,10 +137,10 @@ KDCoordinate BracketLayoutNode::computeChildHeight() {
|
||||
}
|
||||
KDCoordinate siblingHeight = sibling->layoutSize().height();
|
||||
KDCoordinate siblingBaseline = sibling->baseline();
|
||||
maxUnderBaseline = std::max(maxUnderBaseline, siblingHeight - siblingBaseline);
|
||||
maxUnderBaseline = std::max<KDCoordinate>(maxUnderBaseline, siblingHeight - siblingBaseline);
|
||||
maxAboveBaseline = std::max(maxAboveBaseline, siblingBaseline);
|
||||
}
|
||||
return std::max(result, maxUnderBaseline + maxAboveBaseline);
|
||||
return std::max<KDCoordinate>(result, maxUnderBaseline + maxAboveBaseline);
|
||||
}
|
||||
|
||||
KDPoint BracketLayoutNode::positionOfChild(LayoutNode * child) {
|
||||
|
||||
@@ -14,7 +14,7 @@ KDSize CondensedSumLayoutNode::computeSize() {
|
||||
KDSize subscriptSize = subscriptLayout()->layoutSize();
|
||||
KDSize superscriptSize = superscriptLayout()->layoutSize();
|
||||
KDCoordinate sizeWidth = baseSize.width() + std::max(subscriptSize.width(), superscriptSize.width());
|
||||
KDCoordinate sizeHeight = std::max(baseSize.height()/2, subscriptSize.height()) + std::max(baseSize.height()/2, superscriptSize.height());
|
||||
KDCoordinate sizeHeight = std::max<KDCoordinate>(baseSize.height()/2, subscriptSize.height()) + std::max<KDCoordinate>(baseSize.height()/2, superscriptSize.height());
|
||||
return KDSize(sizeWidth, sizeHeight);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ KDPoint CondensedSumLayoutNode::positionOfChild(LayoutNode * child) {
|
||||
}
|
||||
if (child == subscriptLayout()) {
|
||||
x = baseSize.width();
|
||||
y = std::max(baseSize.height()/2, superscriptSize.height());
|
||||
y = std::max<KDCoordinate>(baseSize.height()/2, superscriptSize.height());
|
||||
}
|
||||
if (child == superscriptLayout()) {
|
||||
x = baseSize.width();
|
||||
|
||||
@@ -233,7 +233,7 @@ KDCoordinate GridLayoutNode::rowHeight(int i) const {
|
||||
int j = 0;
|
||||
for (LayoutNode * l : const_cast<GridLayoutNode *>(this)->childrenFromIndex(i*m_numberOfColumns)) {
|
||||
KDCoordinate b = l->baseline();
|
||||
underBaseline = std::max(underBaseline, l->layoutSize().height() - b);
|
||||
underBaseline = std::max<KDCoordinate>(underBaseline, l->layoutSize().height() - b);
|
||||
aboveBaseline = std::max(aboveBaseline, b);
|
||||
j++;
|
||||
if (j >= m_numberOfColumns) {
|
||||
|
||||
@@ -258,7 +258,7 @@ KDSize HorizontalLayoutNode::computeSize() {
|
||||
for (LayoutNode * l : children()) {
|
||||
KDSize childSize = l->layoutSize();
|
||||
totalWidth += childSize.width();
|
||||
maxUnderBaseline = std::max(maxUnderBaseline, childSize.height() - l->baseline());
|
||||
maxUnderBaseline = std::max<KDCoordinate>(maxUnderBaseline, childSize.height() - l->baseline());
|
||||
maxAboveBaseline = std::max(maxAboveBaseline, l->baseline());
|
||||
}
|
||||
return KDSize(totalWidth, maxUnderBaseline + maxAboveBaseline);
|
||||
@@ -310,7 +310,7 @@ KDRect HorizontalLayoutNode::relativeSelectionRect(const Layout * selectionStart
|
||||
for (int i = firstSelectedNodeIndex; i <= secondSelectedNodeIndex; i++) {
|
||||
Layout childi = thisLayout.childAtIndex(i);
|
||||
KDSize childSize = childi.layoutSize();
|
||||
maxUnderBaseline = std::max(maxUnderBaseline, childSize.height() - childi.baseline());
|
||||
maxUnderBaseline = std::max<KDCoordinate>(maxUnderBaseline, childSize.height() - childi.baseline());
|
||||
maxAboveBaseline = std::max(maxAboveBaseline, childi.baseline());
|
||||
}
|
||||
return KDRect(KDPoint(selectionXStart, const_cast<HorizontalLayoutNode *>(this)->baseline() - maxAboveBaseline), KDSize(drawWidth, maxUnderBaseline + maxAboveBaseline));
|
||||
|
||||
@@ -575,7 +575,7 @@ Integer Integer::usum(const Integer & a, const Integer & b, bool subtract, bool
|
||||
carry = (aDigit > result) || (bDigit > result); // There's been an overflow
|
||||
}
|
||||
}
|
||||
size = std::min(size, k_maxNumberOfDigits+oneDigitOverflow);
|
||||
size = std::min<int>(size, k_maxNumberOfDigits+oneDigitOverflow);
|
||||
while (size>0 && s_workingBuffer[size-1] == 0) {
|
||||
size--;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ KDSize NthRootLayoutNode::computeSize() {
|
||||
}
|
||||
|
||||
KDCoordinate NthRootLayoutNode::computeBaseline() {
|
||||
return std::max(
|
||||
return std::max<KDCoordinate>(
|
||||
radicandLayout()->baseline() + k_radixLineThickness + k_heightMargin,
|
||||
adjustedIndexSize().height());
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ KDSize SequenceLayoutNode::computeSize() {
|
||||
}
|
||||
|
||||
KDCoordinate SequenceLayoutNode::computeBaseline() {
|
||||
return std::max(upperBoundLayout()->layoutSize().height()+k_boundHeightMargin+(k_symbolHeight+1)/2, argumentLayout()->baseline());
|
||||
return std::max<KDCoordinate>(upperBoundLayout()->layoutSize().height()+k_boundHeightMargin+(k_symbolHeight+1)/2, argumentLayout()->baseline());
|
||||
}
|
||||
|
||||
KDPoint SequenceLayoutNode::positionOfChild(LayoutNode * l) {
|
||||
@@ -271,7 +271,7 @@ KDCoordinate SequenceLayoutNode::completeLowerBoundX() {
|
||||
}
|
||||
|
||||
KDCoordinate SequenceLayoutNode::subscriptBaseline() {
|
||||
return std::max(std::max(variableLayout()->baseline(), lowerBoundLayout()->baseline()), k_font->stringSize(k_equal).height()/2);
|
||||
return std::max<KDCoordinate>(std::max(variableLayout()->baseline(), lowerBoundLayout()->baseline()), k_font->stringSize(k_equal).height()/2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
static inline int std::min(int x, int y) { return x < y ? x : y; }
|
||||
|
||||
size_t SymbolAbstractNode::size() const {
|
||||
return nodeSize() + strlen(name()) + 1;
|
||||
}
|
||||
@@ -42,7 +40,7 @@ int SymbolAbstractNode::simplificationOrderSameType(const ExpressionNode * e, bo
|
||||
}
|
||||
|
||||
int SymbolAbstractNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return std::min(strlcpy(buffer, name(), bufferSize), bufferSize - 1);
|
||||
return std::min<int>(strlcpy(buffer, name(), bufferSize), bufferSize - 1);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
|
||||
@@ -24,7 +24,7 @@ Layout UndefinedNode::createLayout(Preferences::PrintFloatMode floatDisplayMode,
|
||||
}
|
||||
|
||||
int UndefinedNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return std::min(strlcpy(buffer, Undefined::Name(), bufferSize), bufferSize - 1);
|
||||
return std::min<int>(strlcpy(buffer, Undefined::Name(), bufferSize), bufferSize - 1);
|
||||
}
|
||||
|
||||
template<typename T> Evaluation<T> UndefinedNode::templatedApproximate() const {
|
||||
|
||||
@@ -18,7 +18,7 @@ static inline int absInt(int x) { return x >= 0 ? x : -x; }
|
||||
|
||||
int UnitNode::Prefix::serialize(char * buffer, int bufferSize) const {
|
||||
assert(bufferSize >= 0);
|
||||
return std::min(strlcpy(buffer, m_symbol, bufferSize), bufferSize - 1);
|
||||
return std::min<int>(strlcpy(buffer, m_symbol, bufferSize), bufferSize - 1);
|
||||
}
|
||||
|
||||
bool UnitNode::Representative::canParse(const char * symbol, size_t length,
|
||||
@@ -51,7 +51,7 @@ int UnitNode::Representative::serialize(char * buffer, int bufferSize, const Pre
|
||||
bufferSize -= length;
|
||||
}
|
||||
assert(bufferSize >= 0);
|
||||
length += std::min(strlcpy(buffer, m_rootSymbol, bufferSize), bufferSize - 1);
|
||||
length += std::min<int>(strlcpy(buffer, m_rootSymbol, bufferSize), bufferSize - 1);
|
||||
return length;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ Layout UnitNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int
|
||||
|
||||
int UnitNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
assert(bufferSize >= 0);
|
||||
int underscoreLength = std::min(strlcpy(buffer, "_", bufferSize), bufferSize - 1);
|
||||
int underscoreLength = std::min<int>(strlcpy(buffer, "_", bufferSize), bufferSize - 1);
|
||||
buffer += underscoreLength;
|
||||
bufferSize -= underscoreLength;
|
||||
return underscoreLength + m_representative->serialize(buffer, bufferSize, m_prefix);
|
||||
|
||||
@@ -14,7 +14,7 @@ Layout UnrealNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, in
|
||||
}
|
||||
|
||||
int UnrealNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return std::min(strlcpy(buffer, Unreal::Name(), bufferSize), bufferSize - 1);
|
||||
return std::min<int>(strlcpy(buffer, Unreal::Name(), bufferSize), bufferSize - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user