@@ -60,30 +60,30 @@ pub fn process_unwrap_lamports(accounts: &[AccountInfo], instruction_data: &[u8]
6060 ( source_account. amount ( ) , 0 )
6161 } ;
6262
63- // Comparing whether the AccountInfo's "point" to the same account or
64- // not - this is a faster comparison since it just checks the internal
65- // raw pointer.
66- let self_transfer = source_account_info == destination_account_info;
67-
68- if unlikely ( self_transfer || amount == 0 ) {
63+ if unlikely ( amount == 0 ) {
6964 // Validates the token account owner since we are not writing
7065 // to the account.
7166 check_account_owner ( source_account_info)
7267 } else {
7368 source_account. set_amount ( remaining_amount) ;
7469
75- // SAFETY: single mutable borrow to `source_account_info` lamports.
76- let source_lamports = unsafe { source_account_info. borrow_mut_lamports_unchecked ( ) } ;
77- // Note: The amount of a source token account is already validated and the
78- // `lamports` on the account is always greater than `amount`.
79- * source_lamports -= amount;
70+ // Comparing whether the AccountInfo's "point" to the same account or
71+ // not - this is a faster comparison since it just checks the internal
72+ // raw pointer.
73+ if source_account_info != destination_account_info {
74+ // SAFETY: single mutable borrow to `source_account_info` lamports.
75+ let source_lamports = unsafe { source_account_info. borrow_mut_lamports_unchecked ( ) } ;
76+ // Note: The amount of a source token account is already validated and the
77+ // `lamports` on the account is always greater than `amount`.
78+ * source_lamports -= amount;
8079
81- // SAFETY: single mutable borrow to `destination_account_info` lamports; the
82- // account is already validated to be different from `source_account_info`.
83- let destination_lamports =
84- unsafe { destination_account_info. borrow_mut_lamports_unchecked ( ) } ;
85- // Note: The total lamports supply is bound to `u64::MAX`.
86- * destination_lamports += amount;
80+ // SAFETY: single mutable borrow to `destination_account_info` lamports; the
81+ // account is already validated to be different from `source_account_info`.
82+ let destination_lamports =
83+ unsafe { destination_account_info. borrow_mut_lamports_unchecked ( ) } ;
84+ // Note: The total lamports supply is bound to `u64::MAX`.
85+ * destination_lamports += amount;
86+ }
8787
8888 Ok ( ( ) )
8989 }
0 commit comments