This change moves the state (fixed buffer stream) and methods (decode/read) around decoding a module into a separate struct Decoder so they can be discarded after the module is decoded.
Along with this change, I also fixed a few more things I noticed along the way:
removed version field from Module (unused)
combined common code between min/max limit cases
rename module field to wasm_bin on Module struct to distinguish the wasm binary buffer from the higher level module object
fixed readSlice so it doesn't call skipBytes which unnecessarily
copies the entire slice and throws it away
This change moves the state (fixed buffer stream) and methods (decode/read) around decoding a module into a separate struct
Decoder
so they can be discarded after the module is decoded.Along with this change, I also fixed a few more things I noticed along the way:
module
field towasm_bin
on Module struct to distinguish the wasm binary buffer from the higher level module objectreadSlice
so it doesn't call skipBytes which unnecessarily copies the entire slice and throws it away