zcash_primitives::transaction::fees::transparent::OutputView::serialized_size currently writes a script to a temporary buffer in order to get its length. This could be made slightly more efficient by adding a (possibly crate-private) Script::serialized_size method, since all we need is to know what size the leading CompactSize will be, and then we can add that to the already-encoded inner Vec's length.
zcash_primitives::transaction::fees::transparent::OutputView::serialized_size
currently writes a script to a temporary buffer in order to get its length. This could be made slightly more efficient by adding a (possibly crate-private)Script::serialized_size
method, since all we need is to know what size the leadingCompactSize
will be, and then we can add that to the already-encoded innerVec
's length._Based on a comment originally posted by @str4d in https://github.com/zcash/librustzcash/pull/1257#discussion_r1638072994_