Commit 5bdc026
committed
allkeywords: replace switch with map in GetKeywordID
Long time ago in 74f630c we switched
the implementation of keyword ID lookup in lexer from the map to a large
generated switch. At that time it was more performant, but with the new
swiss table implementation of hash maps in Go I was curious to see
whether the map approach is now faster, and it turns out to be so, so
this commit switches back to the map lookup.
```
name old time/op new time/op delta
Parse/simple-8 12.4µs ± 0% 12.1µs ± 0% -2.05% (p=0.000 n=8+9)
Parse/string-8 18.2µs ± 0% 18.0µs ± 0% -1.24% (p=0.000 n=10+9)
Parse/tpcc-delivery-8 25.0µs ± 0% 24.5µs ± 0% -1.73% (p=0.000 n=10+10)
Parse/account-8 32.9µs ± 0% 32.2µs ± 0% -2.14% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
Parse/simple-8 3.56kB ± 0% 3.56kB ± 0% ~ (all equal)
Parse/string-8 3.83kB ± 0% 3.83kB ± 0% ~ (all equal)
Parse/tpcc-delivery-8 6.14kB ± 0% 6.14kB ± 0% ~ (all equal)
Parse/account-8 11.2kB ± 0% 11.2kB ± 0% ~ (all equal)
name old allocs/op new allocs/op delta
Parse/simple-8 22.0 ± 0% 22.0 ± 0% ~ (all equal)
Parse/string-8 26.0 ± 0% 26.0 ± 0% ~ (all equal)
Parse/tpcc-delivery-8 41.0 ± 0% 41.0 ± 0% ~ (all equal)
Parse/account-8 75.0 ± 0% 75.0 ± 0% ~ (all equal)
```
Release note: None1 parent e670091 commit 5bdc026
File tree
3 files changed
+16
-9
lines changed- pkg
- sql/lexbase/allkeywords
- testutils/lint
3 files changed
+16
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
| 118 | + | |
| 119 | + | |
112 | 120 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
122 | 124 | | |
| 125 | + | |
123 | 126 | | |
124 | 127 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2396 | 2396 | | |
2397 | 2397 | | |
2398 | 2398 | | |
| 2399 | + | |
2399 | 2400 | | |
2400 | 2401 | | |
2401 | 2402 | | |
| |||
0 commit comments