Click here to Skip to main content
15,890,282 members
Articles / Programming Languages / C#
Tip/Trick

Fast Expression Evaluation

Rate me:
Please Sign up or sign in to vote.
3.00/5 (1 vote)
25 Feb 2010CPOL 15.3K   4
Use Expression += Value instead of Expression = Expression + Value. Since Expression can be arbitrarily complex, this can result in lots of unnecessary work. This forces the JIT to evaluate both copies of Expression, and many times this is not needed. The first statement can be optimized far...
Use Expression += Value instead of Expression = Expression + Value.
Since Expression can be arbitrarily complex, this can result in lots of unnecessary work. This forces the JIT to evaluate both copies of Expression, and many times this is not needed. The first statement can be optimized far better than the second, since the JIT can avoid evaluating the Expression twice.

N.B: Expression it self is a Variable not "Expression"..

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Kovair Inc.
India India
I have started programming in 10 years on Fortran 77.Then it was Cobol,C,C++,JAVA 1.2, ASP,JavaScript. Now it at all C# and .NET Framework, such tehnologies as WCF, ADO.NET, ASP.NET, LINQ, ASP.NET Ajax , FLEX and another.

Comments and Discussions

 
QuestionExpression = Expression + Value??? Pin
Rozis24-Feb-10 10:47
Rozis24-Feb-10 10:47 
AnswerRe: Expression = Expression + Value??? [modified] Pin
Palash Biswas25-Feb-10 3:34
Palash Biswas25-Feb-10 3:34 
AnswerRe: Expression = Expression + Value??? Pin
dwilliss25-Feb-10 15:51
dwilliss25-Feb-10 15:51 
GeneralRe: Expression = Expression + Value??? Pin
Palash Biswas25-Feb-10 17:10
Palash Biswas25-Feb-10 17:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.