0

假设您覆盖operator*forpoint3float然后 forfloat并且point3您使用了这样的运算符:

point3 * float

你能知道操作符方法是否会被内联吗?

4

3 回答 3

5

No, you can't tell for sure. In particular, because it's done at JIT time, it will depend on the version of the CLR - and I believe that the 64 bit CLR inlines differently to the 32 bit one as well. It will also depend on whether optimisations are enabled (e.g. whether you're debugging etc).

You can prevent inlining with MethodImplAttribute, but that doesn't help much...

于 2009-02-11T19:20:06.173 回答
2

As far as I know there is no way to know for certain as the JIT is responsible for inlining.

于 2009-02-11T19:19:38.593 回答
2

There is no way to know if a particular method will be inlined or not. C# itself won't ever inline a method call. Only the JITer will do this. While there are certain operations that are likely to be inlined, the JITer makes no guarantees.

于 2009-02-11T19:22:09.523 回答