C
colin
Hi,
I profile my code and find its spending a lot of time doing implicit
conversions from similar structures.
the conversions are mainly things like this
class Point
{
implicit conversion to vector3; //this conversion just returns positon
Vector3 position;
..lots of stuff
}
struct vector3 ///part of library
{
float X,Y,Z;
}
struct lineV3
{
Vector3 A,B;
}
class Wire
{
implicit conversion to lineV3; //this conversion has to create a new
struct
Point A,B;
...lots of other stuff
}
Say I have want a function wich determines the angle between two lines or
wires,
how do I create a generic function wich avoids the implicit conversion of
wire to lineV3 ?
at the moment the function just takes lineV3 and when a wire is passed it
does the conversion
but this is slow, I could copy paste the function to have one for both but
how do I make it generic ? (without adding much code)
I could add an interface to lineV3 and Wire, but then id have to access the
vector3 via properties,
Am i right in thinking this would make it slower or would it get optimised
out if its just simply returns an element?
Colin =^.^=
I profile my code and find its spending a lot of time doing implicit
conversions from similar structures.
the conversions are mainly things like this
class Point
{
implicit conversion to vector3; //this conversion just returns positon
Vector3 position;
..lots of stuff
}
struct vector3 ///part of library
{
float X,Y,Z;
}
struct lineV3
{
Vector3 A,B;
}
class Wire
{
implicit conversion to lineV3; //this conversion has to create a new
struct
Point A,B;
...lots of other stuff
}
Say I have want a function wich determines the angle between two lines or
wires,
how do I create a generic function wich avoids the implicit conversion of
wire to lineV3 ?
at the moment the function just takes lineV3 and when a wire is passed it
does the conversion
but this is slow, I could copy paste the function to have one for both but
how do I make it generic ? (without adding much code)
I could add an interface to lineV3 and Wire, but then id have to access the
vector3 via properties,
Am i right in thinking this would make it slower or would it get optimised
out if its just simply returns an element?
Colin =^.^=