Skip to content

Commit

Permalink
Added default activation dictionary
Browse files Browse the repository at this point in the history
Results in a speed perf of 4 - 5%, but that's not where we're going
to see really good improvements.
  • Loading branch information
jarrettmeyer committed Feb 13, 2012
1 parent 18114a1 commit 60f5caf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion SubSonic.Core/Linq/Structure/ExecutionBuilder.cs
Expand Up @@ -20,6 +20,8 @@ namespace SubSonic.Linq.Structure
/// </summary>
public class ExecutionBuilder : DbExpressionVisitor
{
private static IDictionary<Type, Expression> defaultValueActiviationDictionary = new Dictionary<Type, Expression>();

private readonly List<Expression> initializers = new List<Expression>();
private readonly QueryPolicy policy;
private readonly Expression provider;
Expand Down Expand Up @@ -298,7 +300,12 @@ protected override Expression VisitColumn(ColumnExpression column)
}
else
{
defvalue = Expression.Constant(Activator.CreateInstance(column.Type), column.Type);
// Using a dictionary to cache default types increases performance 4 - 5%
if (!defaultValueActiviationDictionary.TryGetValue(column.Type, out defvalue))
{
defvalue = Expression.Constant(Activator.CreateInstance(column.Type), column.Type);
defaultValueActiviationDictionary.Add(column.Type, defvalue);
}
}

// this sucks, but since we don't track true SQL types through the query, and ADO throws exception if you
Expand Down

0 comments on commit 60f5caf

Please sign in to comment.