开发者

CA2225: Operator overloads have named alternates

Good morning, afternoon or night,

Have you ever wrote anything in which Code Analysis popped up this kind of warnings? If so, did you pay attention to them and implement the friendly alternates? If so, using code repetition to 开发者_Python百科avoid performance breakdowns or using operator calls?

Thank you very much.


If a method only contains a call to another method then most likely the outer method will be inlined into its caller. Which means that there is no performance loss. (Release build without debugger attached).

So I wouldn't duplicate the code and call the operators instead.


Personally I don't really get why the rule exists at all. Shouldn't languages without operator overloading support be able to just manually call the op_SomeThing public static method like any other method?


I do it on public classes of assemblies that are expected not to just see private use, and sometimes beyond that. Still, with one calling into the other, the overhead is negligible if indeed there is any overhead at all (I would expect inlining to mean the latter)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜