hyperledger-iroha / iroha

Iroha - A simple, enterprise-grade decentralized ledger
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
438 stars 280 forks source link

Use `Box<[InstructionBox]>` in `Executable` #5092

Closed dima74 closed 1 month ago

dima74 commented 1 month ago
enum Executable {
    Instructions(Vec<InstructionBox>),
    Wasm(WasmSmartContract),
}

Vec<InstructionBox> in some cases allocates an initial buffer with size 4 (https://github.com/hyperledger/iroha/issues/5083#issuecomment-2364144603). InstructionBox is a large type (176 bytes), so it is worth replacing it with a read-only Box<[InstructionBox]> to be sure we don't waste memory on unused buffer capacity.