Skip to content

Commit

Permalink
Cleanup inline annotations (#2493)
Browse files Browse the repository at this point in the history
Per the [Standard Library development guide](https://std-dev-guide.rust-lang.org/code-considerations/performance/inline.html):

> You can add `#[inline]`:
>
> - To public, small, non-generic functions.
>
> You shouldn't need `#[inline]`:
> - On methods that have any generics in scope.
> - On methods on traits that don't have a default implementation.
>
> `#[inline]` can always be introduced later, so if you're in doubt they can just be removed.

This PR follows this guideline to reduce the number of `#[inline]` annotations in our code, removing the annotation in:
- Non-public functions
- Generic functions
- Medium and big functions.

Hopefully this shouldn't impact our perf at all, but let's wait to see the benchmark results.
  • Loading branch information
jedel1043 committed Dec 20, 2022
1 parent 850a20b commit cc45a82
Show file tree
Hide file tree
Showing 105 changed files with 85 additions and 707 deletions.
1 change: 0 additions & 1 deletion boa_ast/src/expression/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ impl SimplePropertyAccess {
}

/// Creates a `PropertyAccess` AST Expression.
#[inline]
pub fn new<F>(target: Expression, field: F) -> Self
where
F: Into<PropertyAccessField>,
Expand Down
1 change: 0 additions & 1 deletion boa_ast/src/expression/await.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl<T> From<T> for Await
where
T: Into<Box<Expression>>,
{
#[inline]
fn from(e: T) -> Self {
Self { target: e.into() }
}
Expand Down
1 change: 0 additions & 1 deletion boa_ast/src/expression/literal/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ impl<T> From<T> for ArrayLiteral
where
T: Into<Box<[Option<Expression>]>>,
{
#[inline]
fn from(decl: T) -> Self {
Self {
arr: decl.into(),
Expand Down
1 change: 0 additions & 1 deletion boa_ast/src/expression/literal/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ impl<T> From<T> for ObjectLiteral
where
T: Into<Box<[PropertyDefinition]>>,
{
#[inline]
fn from(props: T) -> Self {
Self {
properties: props.into(),
Expand Down
1 change: 1 addition & 0 deletions boa_ast/src/expression/operator/assign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct Assign {

impl Assign {
/// Creates an `Assign` AST Expression.
#[inline]
#[must_use]
pub fn new(op: AssignOp, lhs: AssignTarget, rhs: Expression) -> Self {
Self {
Expand Down
1 change: 1 addition & 0 deletions boa_ast/src/expression/operator/binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct Binary {

impl Binary {
/// Creates a `BinOp` AST Expression.
#[inline]
#[must_use]
pub fn new(op: BinaryOp, lhs: Expression, rhs: Expression) -> Self {
Self {
Expand Down
1 change: 1 addition & 0 deletions boa_ast/src/expression/operator/unary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct Unary {

impl Unary {
/// Creates a new `UnaryOp` AST Expression.
#[inline]
#[must_use]
pub fn new(op: UnaryOp, target: Expression) -> Self {
Self {
Expand Down
9 changes: 4 additions & 5 deletions boa_ast/src/function/async_arrow_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ impl AsyncArrowFunction {
}

/// Sets the name of the function declaration.
//#[inline]
//#[must_use]
//pub fn set_name(&mut self, name: Option<Identifier>) {
// self.name = name;
//}
#[inline]
pub fn set_name(&mut self, name: Option<Identifier>) {
self.name = name;
}

/// Gets the list of parameters of the arrow function.
#[inline]
Expand Down
Loading

0 comments on commit cc45a82

Please sign in to comment.