Skip to content

Commit

Permalink
feat: optimize pushbytes by removing unreachable minimal check
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisCho-H committed Dec 3, 2024
1 parent 733bedd commit 84d1ad5
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/miniscript/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,9 @@ pub fn lex(script: &'_ script::Script) -> Result<Vec<Token<'_>>, Error> {
33 => ret.push(Token::Bytes33(bytes.as_bytes())),
65 => ret.push(Token::Bytes65(bytes.as_bytes())),
_ => {
// check minimality of the number
match script::read_scriptint(bytes.as_bytes()) {
Ok(v) if v >= 0 => {
// check minimality of the number
if script::Builder::new().push_int(v).into_script()[1..].as_bytes()
!= bytes.as_bytes()
{
return Err(Error::InvalidPush(bytes.to_owned().into()));
}
ret.push(Token::Num(v as u32));
}
Ok(_) => return Err(Error::InvalidPush(bytes.to_owned().into())),
Expand Down

0 comments on commit 84d1ad5

Please sign in to comment.