Permalink
Browse files

Four4Sample - improve performance by trying operators before operands

  • Loading branch information...
bobbymcr committed Mar 16, 2018
1 parent 2170934 commit 2e97a5fe1003225af3ce5c30ad8e814a13549091
Showing with 8 additions and 8 deletions.
  1. +8 −8 projects/Four4Sample/Four4/ExpressionSearch.cs
@@ -48,6 +48,14 @@ private bool Run(Expression expr, Func<Expression, bool> each)
}
}
foreach (string op in this.operators)
{
if (!this.Run(expr.Append(op), each))
{
return false;
}
}
if (expr.NumeralCount < 4)
{
foreach (string op in this.operands)
@@ -59,14 +67,6 @@ private bool Run(Expression expr, Func<Expression, bool> each)
}
}
foreach (string op in this.operators)
{
if (!this.Run(expr.Append(op), each))
{
return false;
}
}
return true;
}
}

0 comments on commit 2e97a5f

Please sign in to comment.