Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optimize some stuff #231

Merged
merged 1 commit into from
Aug 15, 2023
Merged

perf: optimize some stuff #231

merged 1 commit into from
Aug 15, 2023

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Aug 15, 2023

  • try_for_each generally generates more llvm-ir and tends to be less optimized than just loop with ?
  • rest of changes are commented below individually

ptr::write_bytes(dst.add(cnt), 0, pad);
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

append_bytes copied 32 bytes at a time, when it can just copy everything at once

@@ -260,7 +260,7 @@ impl SolType for Function {
/// Bytes - `bytes`
pub struct Bytes;

impl<T: AsRef<[u8]>> Encodable<Bytes> for T {
impl<T: ?Sized + AsRef<[u8]>> Encodable<Bytes> for T {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allows:

let x: &[u8] = &[];
Encodable::<Bytes>::to_tokens(x)

debug_assert!(contents.is_empty());
return Ok(())
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

early return for empty sequence

unsafe { Vec::from_raw_parts(Box::into_raw(t), 1, 1) }
} else {
vec![*t; size]
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re use box allocation

@prestwich prestwich merged commit 23d108e into main Aug 15, 2023
18 checks passed
@DaniPopes DaniPopes deleted the dani/abi-perf branch August 16, 2023 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants