Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reduce slice allocation when NODE_DICT type conversion
Before: . . 375: . . 376: case NODE_DICT: . . 377: var kvs []ast.KeyValue . . 378: for _, nn := range n.value.([]interface{}) { . . 379: kv := nn.([]interface{}) . 3MB 380: k := newAstNode(kv[0].(*VimNode)) . 2.50MB 381: v := newAstNode(kv[1].(*VimNode)) 5MB 5MB 382: kvs = append(kvs, ast.KeyValue{Key: k, Value: v}) . . 383: } . . 384: return &ast.Dict{ . . 385: Lcurlybrace: pos, . . 386: Entries: kvs, . . 387: } . . 388: After: . . 375: . . 376: case NODE_DICT: . . 377: entries := n.value.([]interface{}) 2MB 2MB 378: kvs := make([]ast.KeyValue, 0, len(entries)) . . 379: for _, nn := range entries { . . 380: kv := nn.([]interface{}) . 3.50MB 381: k := newAstNode(kv[0].(*VimNode)) . 3.50MB 382: v := newAstNode(kv[1].(*VimNode)) . . 383: kvs = append(kvs, ast.KeyValue{Key: k, Value: v}) . . 384: } . . 385: return &ast.Dict{ . . 386: Lcurlybrace: pos, 1MB 1MB 387: Entries: kvs, . . 388: }
- Loading branch information