Skip to content

Commit b4c7fa0

Browse files
committed
Let the compiler work out int size
We have two places in the code where we pass a mutable parity integer to ffi code. At one callsite we tell the compiler explicitly what type it is (`::secp256k1_sys::types::c_int`) and at the other call site we let the compiler figure out the type. Is one way better than the other? I don't know. But letting the compiler figure it out seems to make the code easier to read.
1 parent c612130 commit b4c7fa0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/key.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ impl XOnlyPublicKey {
11111111
return Err(Error::InvalidTweak);
11121112
}
11131113

1114+
let mut pk_parity = 0;
11141115
unsafe {
11151116
let mut pubkey = ffi::PublicKey::new();
11161117
let mut err = ffi::secp256k1_xonly_pubkey_tweak_add(
@@ -1123,18 +1124,17 @@ impl XOnlyPublicKey {
11231124
return Err(Error::InvalidTweak);
11241125
}
11251126

1126-
let mut parity: ::secp256k1_sys::types::c_int = 0;
11271127
err = ffi::secp256k1_xonly_pubkey_from_pubkey(
11281128
secp.ctx,
11291129
&mut self.0,
1130-
&mut parity,
1130+
&mut pk_parity,
11311131
&pubkey,
11321132
);
11331133
if err == 0 {
11341134
return Err(Error::InvalidPublicKey);
11351135
}
11361136

1137-
Parity::from_i32(parity).map_err(Into::into)
1137+
Parity::from_i32(pk_parity).map_err(Into::into)
11381138
}
11391139
}
11401140

0 commit comments

Comments
 (0)