Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does C# inline properties?

Does C# inline access to properties? I'm aware of the 32 byte (instruction?) limit on the JIT for inlining, but will it inline properties or just pure method calls?

like image 299
thr Avatar asked Mar 14 '09 21:03

thr


People also ask

What is the main cause of hep C?

Hepatitis C is a liver infection caused by the hepatitis C virus (HCV). Hepatitis C is spread through contact with blood from an infected person. Today, most people become infected with the hepatitis C virus by sharing needles or other equipment used to prepare and inject drugs.

What does hep C pain feel like?

Many people with chronic HCV suffer from aches and pains in their joints. A variety of different joints can be involved but the most common are in the hands and wrists. These pains are often minor but occasionally the pain can be quite severe. In such cases painkillers can be used to relieve the symptoms.

How long can you have hep C without knowing?

People with an HCV infection commonly go without noticeable symptoms for as many as 20 to 30 years. Those who are infected experience no significant symptoms when they first acquire the infection, and then they can remain symptomless for years, even while the infection is causing damage to their liver and other organs.

How easy is it to get hep C?

Hepatitis C is spread only through exposure to an infected person's blood. High-risk activities include: Sharing drug use equipment. Anything involved with injecting street drugs, from syringes, to needles, to tourniquets, can have small amounts of blood on it that can transmit hepatitis C.


1 Answers

It's up to the JIT (the C# compiler doesn't do any inlining as far as I'm aware), but I believe the JIT will inline trivial properties in most cases.

Note that it won't inline members of types deriving from MarshalByRefObject which includes System.Windows.Forms.Control (via System.ComponentModel.Component).

I've also seen double fields end up being less efficient when accessed via properties - it could be that there are some subtleties around that (due to register use etc).

Also note that the 64-bit and 32-bit JITs are different, including their treatment of what gets inlined.

EDIT: I've just found a 2004 blog entry by David Notario with some more information. However, that was before 2.0 shipped - I wouldn't be surprised to see that at least some of it had changed now. Might be of interest anyway.

EDIT: Another question referred to a 2008 Vance Morrison blog entry which gives more information. Interesting stuff.

like image 86
Jon Skeet Avatar answered Oct 16 '22 15:10

Jon Skeet