Memory performance improvements
This commit is contained in:
@@ -38,7 +38,6 @@ import jscl.NumeralBase;
|
||||
import jscl.math.numeric.Real;
|
||||
import jscl.text.DoubleParser;
|
||||
import jscl.text.JsclIntegerParser;
|
||||
import jscl.text.MutableInt;
|
||||
import jscl.text.ParseException;
|
||||
import jscl.text.Parser;
|
||||
|
||||
@@ -114,12 +113,16 @@ public class NumberBuilder extends BaseNumberBuilder {
|
||||
try {
|
||||
mc.setNumeralBase(nb);
|
||||
|
||||
final Parser.Parameters p = Parser.Parameters.get(s);
|
||||
try {
|
||||
return JsclIntegerParser.parser.parse(Parser.Parameters.newInstance(s, new MutableInt(0), mc), null).content().doubleValue();
|
||||
return JsclIntegerParser.parser.parse(p, null).content().doubleValue();
|
||||
} catch (ParseException e) {
|
||||
p.exceptionsPool.release(e);
|
||||
try {
|
||||
return ((Real) DoubleParser.parser.parse(Parser.Parameters.newInstance(s, new MutableInt(0), mc), null).content()).doubleValue();
|
||||
p.reset();
|
||||
return ((Real) DoubleParser.parser.parse(p, null).content()).doubleValue();
|
||||
} catch (ParseException e1) {
|
||||
p.exceptionsPool.release(e1);
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
}
|
||||
|
@@ -24,14 +24,11 @@ package org.solovyev.android.calculator.math.edit;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import jscl.text.Identifier;
|
||||
import jscl.text.MutableInt;
|
||||
import jscl.text.ParseException;
|
||||
import jscl.text.Parser;
|
||||
import org.solovyev.android.calculator.VarsRegistry;
|
||||
|
||||
import org.solovyev.android.calculator.EntitiesRegistry;
|
||||
import org.solovyev.android.calculator.Locator;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.VarsRegistry;
|
||||
import org.solovyev.android.calculator.math.MathType;
|
||||
import org.solovyev.android.calculator.model.MathEntityBuilder;
|
||||
import org.solovyev.common.math.MathEntity;
|
||||
@@ -41,6 +38,10 @@ import org.solovyev.common.text.Strings;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import jscl.text.Identifier;
|
||||
import jscl.text.ParseException;
|
||||
import jscl.text.Parser;
|
||||
|
||||
public class VarEditorSaver<T extends MathEntity> implements View.OnClickListener {
|
||||
|
||||
@Nonnull
|
||||
@@ -71,19 +72,16 @@ public class VarEditorSaver<T extends MathEntity> implements View.OnClickListene
|
||||
}
|
||||
|
||||
public static boolean isValidName(@Nullable String name) {
|
||||
boolean result = false;
|
||||
|
||||
if (!Strings.isEmpty(name)) {
|
||||
try {
|
||||
if (name == null) throw new AssertionError();
|
||||
Identifier.parser.parse(Parser.Parameters.newInstance(name, new MutableInt(0), Locator.getInstance().getEngine().getMathEngine()), null);
|
||||
result = true;
|
||||
Identifier.parser.parse(Parser.Parameters.get(name), null);
|
||||
return true;
|
||||
} catch (ParseException e) {
|
||||
// not valid name;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user