From 24cb3b49b19a4cca53cdd532dd6d42a27bdc10a7 Mon Sep 17 00:00:00 2001 From: serso Date: Wed, 20 Apr 2016 13:01:45 +0200 Subject: [PATCH] Remove recursion from MathType --- .../android/calculator/math/MathType.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/math/MathType.java b/app/src/main/java/org/solovyev/android/calculator/math/MathType.java index db21a989..d4c12250 100644 --- a/app/src/main/java/org/solovyev/android/calculator/math/MathType.java +++ b/app/src/main/java/org/solovyev/android/calculator/math/MathType.java @@ -23,21 +23,24 @@ package org.solovyev.android.calculator.math; import android.support.annotation.NonNull; -import jscl.JsclMathEngine; -import jscl.NumeralBase; -import jscl.math.function.Constants; + import org.solovyev.android.Check; import org.solovyev.android.calculator.App; import org.solovyev.android.calculator.Engine; import org.solovyev.android.calculator.ParseException; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import jscl.JsclMathEngine; +import jscl.NumeralBase; +import jscl.math.function.Constants; + public enum MathType { @@ -313,8 +316,8 @@ public enum MathType { if (mathType == MathType.grouping_separator) { if (i + 1 < text.length() && - getType(text, i + 1, hexMode, result, engine).type == MathType.digit && - i - 1 >= 0 && getType(text, i - 1, hexMode, result, engine).type == MathType.digit) { + MathType.digit.getTokens().contains(text.substring(i + 1, i + 2)) && + i - 1 >= 0 && MathType.digit.getTokens().contains(text.substring(i - 1, i))) { return result.set(mathType, s); } continue;