Skip to content

Commit f26bf42

Browse files
committed
Merge #312: Small optimization of Tr descriptor parsing.
00e40e8 Remove double scan for checksum in FromStr (Jeremy Rubin) Pull request description: ACKs for top commit: sanket1729: utACK 00e40e8 Tree-SHA512: 845e724340e70d3d1d5672a8a61bd9f3857328d830cecc33997cece57033ea814b4e5fead702dd3f166703702995ec22e226aef968fd711f0215631b0bd3ed30
2 parents 29bed7e + 00e40e8 commit f26bf42

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)