Skip to content

Commit 1b768b2

Browse files
committed
Make tweak_add_assign return statements uniform
We have two `tweak_add_assign` methods (one for keypair and one for x-only pubkey). Both check the return value from a FFI function call. We can make both sites uniform to _slightly_ reduce cognitive load when reading the code. Use C style code to make it obvious to readers that this is basically C code.
1 parent edafb88 commit 1b768b2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/key.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,11 @@ impl KeyPair {
636636
&mut self.0,
637637
tweak.as_c_ptr(),
638638
);
639-
640-
if err == 1 {
641-
Ok(())
642-
} else {
643-
Err(Error::InvalidTweak)
639+
if err != 1 {
640+
return Err(Error::InvalidTweak);
644641
}
642+
643+
Ok(())
645644
}
646645
}
647646
}
@@ -846,7 +845,6 @@ impl XOnlyPublicKey {
846845
self.as_c_ptr(),
847846
tweak.as_c_ptr(),
848847
);
849-
850848
if err != 1 {
851849
return Err(Error::InvalidTweak);
852850
}

0 commit comments

Comments
 (0)