Skip to content

Commit 00e40e8

Browse files
committed
Remove double scan for checksum in FromStr
1 parent 6cd1fb6 commit 00e40e8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/descriptor/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,12 +739,13 @@ where
739739
type Err = Error;
740740

741741
fn from_str(s: &str) -> Result<Descriptor<Pk>, Error> {
742-
let desc_str = verify_checksum(s)?;
743742
// tr tree parsing has special code
744-
if desc_str.starts_with("tr") {
745-
let tr = Tr::from_str(desc_str)?;
746-
Ok(Descriptor::Tr(tr))
743+
// Tr::from_str will check the checksum
744+
// match "tr(" to handle more extensibly
745+
if s.starts_with("tr(") {
746+
Ok(Descriptor::Tr(Tr::from_str(s)?))
747747
} else {
748+
let desc_str = verify_checksum(s)?;
748749
let top = expression::Tree::from_str(desc_str)?;
749750
expression::FromTree::from_tree(&top)
750751
}

0 commit comments

Comments
 (0)