Git Product home page Git Product logo

Comments (5)

kivimango avatar kivimango commented on June 13, 2024

Second answer

https://internals.rust-lang.org/t/when-should-i-use-inline/598

from x86_64.

AntoineSebert avatar AntoineSebert commented on June 13, 2024

I have followed the link and read the thread, but I still have a question regarding the #[inline] attribute. In C++ an equivalent keyword also exists, but it's merely a hint for the compiler. Does Rust has a similar approach ?

from x86_64.

phil-opp avatar phil-opp commented on June 13, 2024

As far as I know, the #[inline] attribute is just a hint for the compiler that it should consider this function for cross-crate inlining. Without the attribute, inlining across crate bounds is only performed when link time optimization is enabled.

The #[inline] attribute is different from the #[inline(always)] attribute, which always forces inlining and is generally discouraged (because the compiler usually knows it better).

Should all of them be marked #[inline]? Or should users of this crate always depend on LTO?

Forcing the users to always use LTO does not seem like the best solution. So I think it's fine to add #[inline] to all such small functions of this crate and I'm happy to merge a PR for this.

from x86_64.

AntoineSebert avatar AntoineSebert commented on June 13, 2024

I have done #129 .
I'm not 100% sure of my modifications, hopefully it's just a hint, so the observable behaviour should not change.
Tested with cargo build and cargo test.
Did I miss something ?

from x86_64.

phil-opp avatar phil-opp commented on June 13, 2024

Fixed in #129.

from x86_64.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.