c# - How long does variable assignment take? -
i've come across code made liberal use of variables var self = this;
code nicer. while don't think assignments these going significant @ in piece of code, i've wondered how long assignment above take.
with said: how long take, assuming isn't optimized away? how times compare between different languages- e.g. c#, java, , c++? common value types (including pointers)? 32 / 64-bit architectures?
edit: erased part "noticeable difference". meant part side-question, many people have seen , started downvoting me premature optimization (in spite of me highlighting bottleneck part in bold).
the code:
var self = this;
isn't creating new instance of object 'this', referencing pointer object 'this'. @ machine level there 1 pointer since c# compiler optimizes these types of reference out. "how long takes" zero.
so, why 'this'? because makes code easier read.
Comments
Post a Comment