Jump to content
  • Advertisement
Sign in to follow this  
Yratelev

c# Properties and Inlining

This topic is 4815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a Sphere structure such as struct Sphere { float radius; Vector position; } and they are currently private, however, i want to access the position vector publically, but if i make a property public Vector Position { get { return position; } } then because position is a struct, there is a lot of unessacary copying going on. Does the property get inlined at all? thanks Yratelev

Share this post


Link to post
Share on other sites
Advertisement
I am told that the JIT (at least in Release mode) will inline/optimize simple properties like that to the point where they are no more expensive than accessing the fields themselves. That being said, I did notice a significant performance decrease when using Properties over directly accessible fields when I profiled my application, though this could be because the JIT didn't inline the properties, either because I was running in debug mode or because I was running a profiling app alongside.

Share this post


Link to post
Share on other sites
JIT doesn't optimize in debug mode
it doesn't even optimize when you start with debugging when your app is in release mode.
it only optimizes when you start without debugging

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!