diff options
author | Wim <wim@42.be> | 2020-05-24 00:06:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 00:06:21 +0200 |
commit | 393f9e998b1b40aa59d3fb8794c3a73da38c3fb7 (patch) | |
tree | 2bc9b6e6abdbdc6d811b155997597bdae62bc7db /vendor/github.com/d5/tengo/v2/bytecode.go | |
parent | ba0bfe70a8f07164e1341f4b094841acdad5c3a2 (diff) | |
download | matterbridge-msglm-393f9e998b1b40aa59d3fb8794c3a73da38c3fb7.tar.gz matterbridge-msglm-393f9e998b1b40aa59d3fb8794c3a73da38c3fb7.tar.bz2 matterbridge-msglm-393f9e998b1b40aa59d3fb8794c3a73da38c3fb7.zip |
Update dependencies / vendor (#1146)
Diffstat (limited to 'vendor/github.com/d5/tengo/v2/bytecode.go')
-rw-r--r-- | vendor/github.com/d5/tengo/v2/bytecode.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/vendor/github.com/d5/tengo/v2/bytecode.go b/vendor/github.com/d5/tengo/v2/bytecode.go index cfd0d0b5..f3049cee 100644 --- a/vendor/github.com/d5/tengo/v2/bytecode.go +++ b/vendor/github.com/d5/tengo/v2/bytecode.go @@ -97,6 +97,7 @@ func (b *Bytecode) RemoveDuplicates() { var deduped []Object indexMap := make(map[int]int) // mapping from old constant index to new index + fns := make(map[*CompiledFunction]int) ints := make(map[int64]int) strings := make(map[string]int) floats := make(map[float64]int) @@ -106,9 +107,14 @@ func (b *Bytecode) RemoveDuplicates() { for curIdx, c := range b.Constants { switch c := c.(type) { case *CompiledFunction: - // add to deduped list - indexMap[curIdx] = len(deduped) - deduped = append(deduped, c) + if newIdx, ok := fns[c]; ok { + indexMap[curIdx] = newIdx + } else { + newIdx = len(deduped) + fns[c] = newIdx + indexMap[curIdx] = newIdx + deduped = append(deduped, c) + } case *ImmutableMap: modName := inferModuleName(c) newIdx, ok := immutableMaps[modName] |