From bd8d51fc9570f89dc21375b26387d73d76ef76c8 Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 1 Apr 2020 22:50:56 +0800 Subject: [PATCH] token: small optimizations --- vlib/v/token/token.v | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/vlib/v/token/token.v b/vlib/v/token/token.v index c3643c7178..05a1a893ac 100644 --- a/vlib/v/token/token.v +++ b/vlib/v/token/token.v @@ -134,7 +134,7 @@ const ( // Keywords['return'] == .key_return fn build_keys() map[string]int { mut res := map[string]int - for t := int(Kind.keyword_beg) + 1; t < int(Kind.keyword_end); t++ { + for t in int(Kind.keyword_beg) + 1 .. int(Kind.keyword_end) { key := token_str[t] res[key] = t } @@ -144,8 +144,6 @@ fn build_keys() map[string]int { // TODO remove once we have `enum Kind { name('name') if('if') ... }` fn build_token_str() []string { mut s := [''].repeat(nr_tokens) - s[Kind.keyword_beg] = '' - s[Kind.keyword_end] = '' s[Kind.eof] = 'eof' s[Kind.name] = 'name' s[Kind.number] = 'number' @@ -282,21 +280,6 @@ fn (t []Kind) contains(val Kind) bool { } pub fn (t Kind) str() string { - if t == .number { - return 'number' - } - if t == .chartoken { - return 'char' // '`lit`' - } - if t == .string { - return 'str' // "'lit'" - } - /* - if t < .plus { - return lit // string, number etc - } - */ - return token_str[int(t)] } @@ -312,7 +295,6 @@ pub const ( ) */ - pub enum Precedence { lowest cond // OR or AND