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

Add #[inline] attribute to small functions #129

Merged
merged 1 commit into from
Feb 26, 2020
Merged

Add #[inline] attribute to small functions #129

merged 1 commit into from
Feb 26, 2020

Conversation

AntoineSebert
Copy link
Contributor

I tried to mark as inlined functions that I estimated suitable, up to 4 lines of codes or distinct language statements/expressions.
I discarded operator overloadings and new().
Hope that helps !

@phil-opp
Copy link
Member

Looks good to me, thanks!

I just tried this PR on blog_os and it leads to a slightly smaller executable size:

Before:

  text	   data	    bss	    dec	    hex	filename
  47552	   2838	   8632	  59022	   e68e	target/x86_64-blog_os/release/blog_os

After:

   text	   data	    bss	    dec	    hex	filename
  46640	   2718	   8632	  57990	   e286	target/x86_64-blog_os/release/blog_os

@phil-opp phil-opp merged commit 583f008 into rust-osdev:master Feb 26, 2020
phil-opp added a commit that referenced this pull request Feb 26, 2020
@phil-opp
Copy link
Member

Released as version 0.9.5

@m-ou-se
Copy link
Contributor

m-ou-se commented Apr 11, 2020

Is there any reason the operator implementations (Add, Sub, etc.) should not be made #[inline] too, considering they are also mostly trivial functions? (If not, I'll send a PR for that.)

@phil-opp
Copy link
Member

Given that the standard library does this, I think it would be fine if we do it too.

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.

3 participants