stellar / soroban-examples

Example Soroban Contracts
Apache License 2.0
65 stars 68 forks source link

Remove unnecessary clones from metadata #119

Open jonjove opened 2 years ago

leighmcculloch commented 2 years ago

Is this related to SDK types not being Copy? I'm starting to think we should consider making all the SDK types Copy, given that the SDK types are mostly backed by a u64. Unsure if that has drawbacks though. cc @graydon

jonjove commented 2 years ago

Not really, there are just some places where a clone was made but you could have just moved. For example, https://github.com/stellar/soroban-token-contract/blob/44127bca3ee1dcf3d8107db6fa60077e7ec3dff8/src/metadata.rs#L14-L17

I've also wondered about making everything Copy, and think it could have benefits. There might also be disadvantages though.

leighmcculloch commented 2 years ago

I've also wondered about making everything Copy, and think it could have benefits.

Unfortunately plenty of SDK types, the ones that embed Env, cannot be Copy because the Env contains an Rc<>. It would be nice if we could make some of the types Copy, especially types like BigInt.

jonjove commented 2 years ago

This is already done in the built-in token contract but is not done in the example token contract.