From b193df8b42b172cb9fc5a25724ae38a2dae3607c Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 2 Nov 2018 13:56:11 +0100 Subject: [PATCH] tinyexpr: Move enums together and stop explicit numbering We should _not_ be doing bit-fiddling with these, so there's no reason to care about the number. This also removes the unused "TE_VARIABLE" symbol. --- src/tinyexpr.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/tinyexpr.cpp b/src/tinyexpr.cpp index 8d955d274..1fa9ebb36 100644 --- a/src/tinyexpr.cpp +++ b/src/tinyexpr.cpp @@ -38,8 +38,10 @@ typedef double (*te_fun1)(double); typedef double (*te_fun0)(); enum { - TE_VARIABLE = 0, TE_CONSTANT, - TE_FUNCTION0 = 8, TE_FUNCTION1, TE_FUNCTION2, TE_FUNCTION3 + TE_CONSTANT = 0, + TE_FUNCTION0, TE_FUNCTION1, TE_FUNCTION2, TE_FUNCTION3, + TOK_NULL, TOK_ERROR, TOK_END, TOK_SEP, + TOK_OPEN, TOK_CLOSE, TOK_NUMBER, TOK_INFIX }; int get_arity(const int type) { @@ -49,12 +51,6 @@ int get_arity(const int type) { return 0; } -// TODO: Is it actually used that these share a space? -enum { - TOK_NULL = TE_FUNCTION0+16, TOK_ERROR, TOK_END, TOK_SEP, - TOK_OPEN, TOK_CLOSE, TOK_NUMBER, TOK_INFIX -}; - typedef struct te_expr { int type; union {double value; const void *function;}; @@ -465,7 +461,6 @@ double te_eval(const te_expr *n) { static void optimize(te_expr *n) { /* Evaluates as much as possible. */ if (n->type == TE_CONSTANT) return; - if (n->type == TE_VARIABLE) return; const int arity = get_arity(n->type); bool known = true;