We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 866744c + 245dd08 commit 2783351Copy full SHA for 2783351
go/vimlfunc.go
@@ -147,6 +147,20 @@ func viml_string(obj interface{}) string {
147
}
148
149
func viml_has_key(obj interface{}, key interface{}) bool {
150
+ // Avoid using reflect as much as possible by listing type used as obj and
151
+ // use type switch.
152
+ switch o := obj.(type) {
153
+ case map[string]*Cmd:
154
+ _, ok := o[key.(string)]
155
+ return ok
156
+ case map[string]interface{}:
157
158
159
+ case map[int][]interface{}:
160
+ _, ok := o[key.(int)]
161
162
+ }
163
+ // fallback to reflect. Shoul be unreachable.
164
m := reflect.ValueOf(obj)
165
v := m.MapIndex(reflect.ValueOf(key))
166
return v.Kind() != reflect.Invalid
0 commit comments