-
Notifications
You must be signed in to change notification settings - Fork 153
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
Conversation
ptr::write_bytes(dst.add(cnt), 0, pad); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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(()) | ||
} | ||
|
There was a problem hiding this comment.
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] | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re use box allocation
try_for_each
generally generates more llvm-ir and tends to be less optimized than just loop with?