From 303ab7f009582b4f24e9323751ee56ed8490f40e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Tue, 4 Dec 2018 10:11:26 +0100 Subject: [PATCH] [apps/graph] Clean code in graph/graph_controller.cpp --- apps/graph/graph/graph_controller.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/graph/graph/graph_controller.cpp b/apps/graph/graph/graph_controller.cpp index 605dea77f..c0bb4e0fc 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -5,6 +5,8 @@ using namespace Shared; namespace Graph { +static inline float max(float x, float y) { return (x>y ? x : y); } + GraphController::GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, StorageCartesianFunctionStore * functionStore, Shared::InteractiveCurveViewRange * curveViewRange, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header) : StorageFunctionGraphController(parentResponder, inputEventHandlerDelegate, header, curveViewRange, &m_view, cursor, indexFunctionSelectedByCursor, modelVersion, rangeVersion, angleUnitVersion), m_bannerView(), @@ -44,10 +46,10 @@ float GraphController::interestingXRange() { ExpiringPointer f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i)); float fRange = f->expressionReduced(myApp->localContext()).characteristicXRange(*(myApp->localContext()), Poincare::Preferences::sharedPreferences()->angleUnit()); if (!std::isnan(fRange)) { - characteristicRange = fRange > characteristicRange ? fRange : characteristicRange; + characteristicRange = max(fRange, characteristicRange); } } - return (characteristicRange > 0.0f ? 1.6f*characteristicRange : 10.0f); + return (characteristicRange > 0.0f ? 1.6f*characteristicRange : InteractiveCurveViewRangeDelegate::interestingXRange()); } int GraphController::estimatedBannerNumberOfLines() const {