Do inner functions have a negative impact on the performance

I figured out a few days ago that I can use inner functions to make my code look more clean

//Helper function to prevent using too long function calls in multiple variables
    async fn get_val(key: &str) -> Result<String, Error> {
        vault_access::get_value(key)
            .await
            .map_err(|e|
                Error::Io(Err::new(ErrorKind::Other, e.to_string()))
            )
    }

    let db_user = get_val("DB_USER").await?;
    let db_pass = get_val("DB_PASSWORD").await?;

Does this have a negative impanct on my performance?

1 Like

Function calls are extremely cheap, and often zero cost because they are inlined by the compiler. Function calls are not a performance consideration.

1 Like

The async-block futures returned by async fns, however, are subject to not very much optimization and can sometimes have noticeable costs (mostly in the size of the future, if you nest deeply).

2 Likes