Have a question about how to better optimize or speed things up. Currently my code seems to be running a bit slow...
I have the following classes
public class DataFoo : IFoo { }
public class Foo
{
internal IFoo UnderlyingDataObject{get;set;}
public Foo(IFoo f)
{
UnderlyingDataObject = f;
}
}
Now, in many cases I end up needing or calling a method that will provide back a List. This method will initially get a array of DataFoo objects and will iterate over all returned objects instantiating a new Foo object passing in the DataFoo... Here's an example...
public List<Foo> GetListOfFoo(Guid id)
{
DataFoo[] q = GetArrayOfDataFoo(id);
List<Foo> rv = new List<Foo>();
for(var i = 0; i < q.Length; i++)
{
rv.Add(new Foo(q[i]));
}
return rv;
}
The issue is that having to iterate over and instantiate like this seems pretty slow. I was curious if anyone might have suggestions on how to speed this up...