Skip to content

Commit

Permalink
more optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
chaowlert committed Jan 19, 2016
1 parent 1f713f4 commit 4eb1972
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 768 deletions.
8 changes: 4 additions & 4 deletions src/Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ private static void TestSimpleTypes()

TestSimple(foo, 10000);

//TestSimple(foo, 100000);
TestSimple(foo, 100000);

//TestSimple(foo, 1000000);
TestSimple(foo, 1000000);
}

private static void TestComplexTypes()
Expand Down Expand Up @@ -112,11 +112,11 @@ private static void TestSimple(Foo item, int iterations)

TestMapsterAdapter<Foo, Foo>(item, iterations);

TestValueInjecter<Foo, Foo>(item, iterations);
//TestValueInjecter<Foo, Foo>(item, iterations);

TestExpressMapper<Foo, Foo>(item, iterations);

TestAutoMapper<Foo, Foo>(item, iterations);
//TestAutoMapper<Foo, Foo>(item, iterations);
}


Expand Down
8 changes: 7 additions & 1 deletion src/Mapster/Adapters/CollectionAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ protected override Expression CreateBlockExpression(Expression source, Expressio
{
if (destination.Type.IsArray)
{
return CreateArraySet(source, destination, arg);
if (source.Type.IsArray && source.Type.GetElementType() == destination.Type.GetElementType())
{
var method = typeof (Array).GetMethod("Copy", new[] {typeof (Array), typeof (int), typeof (Array), typeof (int), typeof (int)});
return Expression.Call(method, source, Expression.Constant(0), destination, Expression.Constant(0), Expression.ArrayLength(source));
}
else
return CreateArraySet(source, destination, arg);
}
else
{
Expand Down
Loading

0 comments on commit 4eb1972

Please sign in to comment.