c# - does, myval = (someconditon) ? someVal : myval get optimized to not set the value in case it's false -
cpath = (cpath == null) ? request.path : cpath;
first of wish clr let me ? request.path , not bother me creating :
but i'm asking optimize away? or still assign.
well, write as:
if (cpath == null) { cpath = request.path; }
to make clearer. alternative (as mentioned elsewhere) is
cpath = cpath ?? request.path;
but why care if there's assignment? really think that's going significant performance hit?
note if cpath
field rather local variable, potentially make difference - because value of cpath
change between first check , second evaluation, , again between evaluation , assignment. whether noticed depends on caching etc, it's not simple might @ first.
Comments
Post a Comment