From a7376c72a76895cffd6c66f951418f825bcc62c8 Mon Sep 17 00:00:00 2001 From: vedhavyas Date: Tue, 20 Aug 2019 14:09:38 -0700 Subject: [PATCH] cach memory instead --- bridge.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bridge.go b/bridge.go index f4cd989..3cc1134 100644 --- a/bridge.go +++ b/bridge.go @@ -41,6 +41,7 @@ type Bridge struct { exitCode int values []interface{} refs map[interface{}]int + memory []byte } func BridgeFromBytes(name string, bytes []byte, imports *wasmer.Imports) (*Bridge, error) { @@ -176,7 +177,11 @@ func (b *Bridge) Run(init chan error, done chan bool) { } func (b *Bridge) mem() []byte { - return b.instance.Memory.Data() + if b.memory == nil { + b.memory = b.instance.Memory.Data() + } + + return b.memory } func (b *Bridge) getSP() int32 {