-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
macro_rules! implement_deploy_account_tx_getters {
($(($field:ident, $field_type:ty)),*) => {
$(
pub fn $field(&self) -> $field_type {
match self {
Self::V1(tx) => tx.$field.clone(),
Self::V3(tx) => tx.$field.clone(),
}
}
)*
};
}
...
impl DeployAccountTransaction {
implement_deploy_account_tx_getters!(
(class_hash, ClassHash),
(constructor_calldata, Calldata),
(contract_address_salt, ContractAddressSalt),
(nonce, Nonce),
(signature, TransactionSignature)
);Calling clone is not a problem for types that implement copy, but for types that don't. Like TransactionSignature, it means that a clone operation always occurs, even when the caller has no need for ownership of the value and could have used a reference.
This has a performance cost and is overall a bad design for an API: the method should not assume anything about the caller intentions
Metadata
Metadata
Assignees
Labels
No labels