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

Remove all instance of inline #1019

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions crates/allocator/src/bump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ static mut INNER: InnerAlloc = InnerAlloc::new();
pub struct BumpAllocator;

unsafe impl GlobalAlloc for BumpAllocator {
#[inline]
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
match INNER.alloc(layout) {
Some(start) => start as *mut u8,
None => core::ptr::null_mut(),
}
}

#[inline]
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
// A new page in Wasm is guaranteed to already be zero initialized, so we can just use our
// regular `alloc` call here and save a bit of work.
Expand All @@ -52,7 +50,6 @@ unsafe impl GlobalAlloc for BumpAllocator {
self.alloc(layout)
}

#[inline]
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
}

Expand Down Expand Up @@ -142,7 +139,6 @@ impl InnerAlloc {
/// This function rounds up to the next page. For example, if we have an allocation of
/// `size = PAGE_SIZE / 2` this function will indicate that one page is required to satisfy
/// the allocation.
#[inline]
fn required_pages(size: usize) -> Option<usize> {
size.checked_add(PAGE_SIZE - 1)
.and_then(|num| num.checked_div(PAGE_SIZE))
Expand Down
1 change: 0 additions & 1 deletion crates/engine/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ macro_rules! define_error_codes {
}

impl From<ReturnCode> for Result {
#[inline]
fn from(return_code: ReturnCode) -> Self {
match return_code.0 {
0 => Ok(()),
Expand Down
10 changes: 0 additions & 10 deletions crates/env/src/call/call_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,26 @@ where
E: Environment,
{
/// Returns the account ID of the called contract instance.
#[inline]
pub(crate) fn callee(&self) -> &E::AccountId {
&self.callee
}

/// Returns the call flags.
#[inline]
pub(crate) fn call_flags(&self) -> &CallFlags {
&self.call_flags
}

/// Returns the chosen gas limit for the called contract execution.
#[inline]
pub(crate) fn gas_limit(&self) -> u64 {
self.gas_limit
}

/// Returns the transferred value for the called contract.
#[inline]
pub(crate) fn transferred_value(&self) -> &E::Balance {
&self.transferred_value
}

/// Returns the execution input.
#[inline]
pub(crate) fn exec_input(&self) -> &ExecutionInput<Args> {
&self.exec_input
}
Expand Down Expand Up @@ -240,7 +235,6 @@ where
E: Environment,
{
/// Sets the called smart contract instance account ID to the given value.
#[inline]
pub fn callee(
self,
callee: E::AccountId,
Expand All @@ -264,7 +258,6 @@ where
E: Environment,
{
/// The flags used to change the behavior of the contract call.
#[inline]
pub fn call_flags(
self,
call_flags: CallFlags,
Expand All @@ -287,7 +280,6 @@ where
E: Environment,
{
/// Sets the maximum allowed gas costs for the call.
#[inline]
pub fn gas_limit(
self,
gas_limit: u64,
Expand All @@ -310,7 +302,6 @@ where
E: Environment,
{
/// Sets the value transferred upon the execution of the call.
#[inline]
pub fn transferred_value(
self,
transferred_value: E::Balance,
Expand Down Expand Up @@ -351,7 +342,6 @@ where
/// Either use `.returns::<()>` to signal that the call does not return a value
/// or use `.returns::<ReturnType<T>>` to signal that the call returns a value of
/// type `T`.
#[inline]
pub fn returns<R>(
self,
) -> CallBuilder<E, Callee, GasLimit, TransferredValue, Args, Set<R>>
Expand Down
7 changes: 0 additions & 7 deletions crates/env/src/call/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use core::marker::PhantomData;
pub struct ReturnType<T>(PhantomData<fn() -> T>);

impl<T> Clone for ReturnType<T> {
#[inline]
fn clone(&self) -> Self {
Self(Default::default())
}
Expand All @@ -32,7 +31,6 @@ impl<T> Clone for ReturnType<T> {
impl<T> Copy for ReturnType<T> {}

impl<T> Default for ReturnType<T> {
#[inline]
fn default() -> Self {
Self(Default::default())
}
Expand All @@ -44,7 +42,6 @@ pub struct Set<T>(pub T);

impl<T> Set<T> {
/// Returns the set value.
#[inline]
pub fn value(self) -> T {
self.0
}
Expand All @@ -55,7 +52,6 @@ impl<T> Set<T> {
pub struct Unset<T>(PhantomData<fn() -> T>);

impl<T> Clone for Unset<T> {
#[inline]
fn clone(&self) -> Self {
Self(Default::default())
}
Expand All @@ -64,7 +60,6 @@ impl<T> Clone for Unset<T> {
impl<T> Copy for Unset<T> {}

impl<T> Default for Unset<T> {
#[inline]
fn default() -> Self {
Self(Default::default())
}
Expand All @@ -87,7 +82,6 @@ pub trait Unwrap {
impl<T> Unwrap for Unset<T> {
type Output = T;

#[inline]
fn unwrap_or_else<F>(self, f: F) -> Self::Output
where
F: FnOnce() -> Self::Output,
Expand All @@ -99,7 +93,6 @@ impl<T> Unwrap for Unset<T> {
impl<T> Unwrap for Set<T> {
type Output = T;

#[inline]
fn unwrap_or_else<F>(self, _: F) -> Self::Output
where
F: FnOnce() -> Self::Output,
Expand Down
13 changes: 0 additions & 13 deletions crates/env/src/call/create_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,21 @@ where
E: Environment,
{
/// The code hash of the contract.
#[inline]
pub(crate) fn code_hash(&self) -> &E::Hash {
&self.code_hash
}

/// The gas limit for the contract instantiation.
#[inline]
pub(crate) fn gas_limit(&self) -> u64 {
self.gas_limit
}

/// The endowment for the instantiated contract.
#[inline]
pub(crate) fn endowment(&self) -> &E::Balance {
&self.endowment
}

/// The raw encoded input data.
#[inline]
pub(crate) fn exec_input(&self) -> &ExecutionInput<Args> {
&self.exec_input
}
Expand All @@ -105,7 +101,6 @@ where
Salt: AsRef<[u8]>,
{
/// The salt for determining the hash for the contract account ID.
#[inline]
pub(crate) fn salt_bytes(&self) -> &Salt {
&self.salt_bytes
}
Expand All @@ -119,7 +114,6 @@ where
R: FromAccountId<E>,
{
/// Instantiates the contract and returns its account ID back to the caller.
#[inline]
pub fn instantiate(&self) -> Result<R, crate::Error> {
crate::instantiate_contract(self).map(FromAccountId::from_account_id)
}
Expand Down Expand Up @@ -218,7 +212,6 @@ where
E: Environment,
{
/// Sets the used code hash for the contract instantiation.
#[inline]
pub fn code_hash(
self,
code_hash: E::Hash,
Expand All @@ -241,7 +234,6 @@ where
E: Environment,
{
/// Sets the maximum allowed gas costs for the contract instantiation.
#[inline]
pub fn gas_limit(
self,
gas_limit: u64,
Expand All @@ -264,7 +256,6 @@ where
E: Environment,
{
/// Sets the value transferred upon the execution of the call.
#[inline]
pub fn endowment(
self,
endowment: E::Balance,
Expand Down Expand Up @@ -295,7 +286,6 @@ where
E: Environment,
{
/// Sets the value transferred upon the execution of the call.
#[inline]
pub fn exec_input<Args>(
self,
exec_input: ExecutionInput<Args>,
Expand All @@ -319,7 +309,6 @@ where
E: Environment,
{
/// Sets the value transferred upon the execution of the call.
#[inline]
pub fn salt_bytes<Salt>(
self,
salt: Salt,
Expand Down Expand Up @@ -354,7 +343,6 @@ where
GasLimit: Unwrap<Output = u64>,
{
/// Sets the value transferred upon the execution of the call.
#[inline]
pub fn params(self) -> CreateParams<E, Args, Salt, R> {
CreateParams {
code_hash: self.code_hash.value(),
Expand Down Expand Up @@ -385,7 +373,6 @@ where
R: FromAccountId<E>,
{
/// Instantiates the contract using the given instantiation parameters.
#[inline]
pub fn instantiate(self) -> Result<R, Error> {
self.params().instantiate()
}
Expand Down
15 changes: 0 additions & 15 deletions crates/env/src/call/execution_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub struct ExecutionInput<Args> {

impl ExecutionInput<EmptyArgumentList> {
/// Creates a new execution input with the given selector.
#[inline]
pub fn new(selector: Selector) -> Self {
Self {
selector,
Expand All @@ -34,7 +33,6 @@ impl ExecutionInput<EmptyArgumentList> {
}

/// Pushes an argument to the execution input.
#[inline]
pub fn push_arg<T>(
self,
arg: T,
Expand All @@ -51,7 +49,6 @@ impl ExecutionInput<EmptyArgumentList> {

impl<'a, Head, Rest> ExecutionInput<ArgumentList<Argument<Head>, Rest>> {
/// Pushes an argument to the execution input.
#[inline]
pub fn push_arg<T>(self, arg: T) -> ExecutionInput<ArgsList<T, ArgsList<Head, Rest>>>
where
T: scale::Encode,
Expand Down Expand Up @@ -92,7 +89,6 @@ pub struct Argument<T> {

impl<T> Argument<T> {
/// Creates a new argument.
#[inline]
fn new(arg: T) -> Self {
Self { arg }
}
Expand All @@ -107,7 +103,6 @@ pub type EmptyArgumentList = ArgumentList<ArgumentListEnd, ArgumentListEnd>;

impl EmptyArgumentList {
/// Creates a new empty argument list.
#[inline]
pub fn empty() -> EmptyArgumentList {
ArgumentList {
head: ArgumentListEnd,
Expand All @@ -116,7 +111,6 @@ impl EmptyArgumentList {
}

/// Pushes the first argument to the empty argument list.
#[inline]
pub fn push_arg<T>(self, arg: T) -> ArgumentList<Argument<T>, Self>
where
T: scale::Encode,
Expand All @@ -130,7 +124,6 @@ impl EmptyArgumentList {

impl<Head, Rest> ArgumentList<Argument<Head>, Rest> {
/// Pushes another argument to the argument list.
#[inline]
pub fn push_arg<T>(self, arg: T) -> ArgumentList<Argument<T>, Self>
where
T: scale::Encode,
Expand All @@ -146,24 +139,20 @@ impl<T> scale::Encode for Argument<T>
where
T: scale::Encode,
{
#[inline]
fn size_hint(&self) -> usize {
<T as scale::Encode>::size_hint(&self.arg)
}

#[inline]
fn encode_to<O: scale::Output + ?Sized>(&self, output: &mut O) {
<T as scale::Encode>::encode_to(&self.arg, output)
}
}

impl scale::Encode for EmptyArgumentList {
#[inline]
fn size_hint(&self) -> usize {
0
}

#[inline]
fn encode_to<O: scale::Output + ?Sized>(&self, _output: &mut O) {}
}

Expand All @@ -172,12 +161,10 @@ where
Head: scale::Encode,
Rest: scale::Encode,
{
#[inline]
fn size_hint(&self) -> usize {
scale::Encode::size_hint(&self.head) + scale::Encode::size_hint(&self.rest)
}

#[inline]
fn encode_to<O: scale::Output + ?Sized>(&self, output: &mut O) {
// We reverse the order of encoding because we build up the list of
// arguments in reverse order, too. This way we encode the arguments
Expand All @@ -192,12 +179,10 @@ impl<Args> scale::Encode for ExecutionInput<Args>
where
Args: scale::Encode,
{
#[inline]
fn size_hint(&self) -> usize {
scale::Encode::size_hint(&self.selector) + scale::Encode::size_hint(&self.args)
}

#[inline]
fn encode_to<O: scale::Output + ?Sized>(&self, output: &mut O) {
scale::Encode::encode_to(&self.selector, output);
scale::Encode::encode_to(&self.args, output);
Expand Down
Loading