Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem you describe is severe in the sense that evaluating two expressions for <strong>semantic</strong> equality is at least as expensive as compiling the expression. To illustrate this, <a href="http://badecho.com/2012/02/expression-equality-comparer-part-i/" rel="nofollow noreferrer">here</a> is a link to an implementation for expression equality. This implementation is not perfect, for example:</p> <pre><code>MethodA() { MethodB(); } MethodB() { ... } </code></pre> <p>In the example above, <code>MethodA</code> and <code>MethodB</code> are equivalent in the sense that they do the same thing, and you most likely want to consider them as equivalent. For example, building this in C# with compiler optimization enabled will replace the <code>MethodB</code> call with <code>MethodA</code> calls. There are a myriad of issues when comparing code and it is a topic of ongoing research.</p> <p>You should consider a design where expressions are referenced by some kind of key that identifies it if you find out that compiling the expressions is the bottleneck in your application. <strong>By the time you have determined equality you could have already compiled it.</strong></p> <p>To comment on J0HN's answer, it compares the hash code of the body and the parameters, this is by no means a reliable solution, since it does not do a deep evaluation of the expression tree.</p> <p>Also, take a look at <a href="https://stackoverflow.com/questions/283537/most-efficient-way-to-test-equality-of-lambda-expressions">this question</a> as posted in the comments.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload