Skip to content

Commit

Permalink
Create a tree map from lowercase built-in function name to ID number
Browse files Browse the repository at this point in the history
- BuiltinUsage#summaryText(String) doesn't require F.await() anymore,
which leads to performance issue in Android UI thread.
  • Loading branch information
axkr committed Sep 30, 2023
1 parent a136716 commit d3d7a31
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package org.matheclipse.core.expression;

import java.util.concurrent.atomic.AtomicBoolean;
import org.matheclipse.core.interfaces.IBuiltInSymbol;

public class BuiltinUsage {
private static final String[] USAGE = new String[ID.Zeta + 10];

private static AtomicBoolean IS_INITIALIZED = new AtomicBoolean();

public static synchronized void init() {
IS_INITIALIZED.set(true);

static {
USAGE[ID.$IterationLimit] =
"specifies the maximum number of times a reevaluation of an expression may happen";

Expand Down Expand Up @@ -619,9 +614,9 @@ public static String summaryText(String symbolStr) {
*
*/
public static String summaryText(IBuiltInSymbol symbol) {
if (!IS_INITIALIZED.get()) {
init();
}
// if (!IS_INITIALIZED.get()) {
// init();
// }
String str = USAGE[symbol.ordinal()];
return str != null ? str : "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2126,7 +2126,6 @@ public class ID {
public final static Map<String, Integer> STRING_TO_ID_MAP = new TreeMap<String, Integer>();

static {

for (int i = 0; i < FUNCTION_NAMES.length; i++) {
STRING_TO_ID_MAP.put(FUNCTION_NAMES[i], i);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class FunctionIDGenerator {
+ " public final static Map<String, Integer> STRING_TO_ID_MAP = new TreeMap<String, Integer>();\n" //
+ "\n" //
+ " static {\n" //
+ "\n" //
+ " for (int i = 0; i < FUNCTION_NAMES.length; i++) {\n" //
+ " STRING_TO_ID_MAP.put(FUNCTION_NAMES[i], i);\n" //
+ " }\n" //
Expand Down

0 comments on commit d3d7a31

Please sign in to comment.