Use std::min and std::max

This commit is contained in:
Romain Goyet
2020-04-12 15:43:39 -04:00
committed by Ecco
parent 77ee5126e1
commit 950862f8d0
79 changed files with 297 additions and 406 deletions

View File

@@ -1,11 +1,10 @@
#include "expression_model_list_controller.h"
#include <apps/constant.h>
#include <poincare/symbol.h>
#include <algorithm>
namespace Shared {
static inline int minInt(int x, int y) { return x < y ? x : y; }
/* Table Data Source */
ExpressionModelListController::ExpressionModelListController(Responder * parentResponder, I18n::Message text) :
@@ -121,7 +120,7 @@ int ExpressionModelListController::memoizedIndexFromCumulatedHeight(KDCoordinate
KDCoordinate currentCumulatedHeight = memoizedCumulatedHeightFromIndex(currentSelectedRow);
if (offsetY > currentCumulatedHeight) {
int iMax = minInt(k_memoizedCellsCount/2 + 1, rowsCount - currentSelectedRow);
int iMax = std::min(k_memoizedCellsCount/2 + 1, rowsCount - currentSelectedRow);
for (int i = 0; i < iMax; i++) {
currentCumulatedHeight+= memoizedRowHeight(currentSelectedRow + i);
if (offsetY <= currentCumulatedHeight) {
@@ -129,7 +128,7 @@ int ExpressionModelListController::memoizedIndexFromCumulatedHeight(KDCoordinate
}
}
} else {
int iMax = minInt(k_memoizedCellsCount/2, currentSelectedRow);
int iMax = std::min(k_memoizedCellsCount/2, currentSelectedRow);
for (int i = 1; i <= iMax; i++) {
currentCumulatedHeight-= memoizedRowHeight(currentSelectedRow-i);
if (offsetY > currentCumulatedHeight) {