optimization# Programming - 葵花宝典
c*e
1 楼
struct Node
{
int i;
int j;
int k;
};
bool compare1 (const Node& n1, const Node& n2)
{
return (n1.i < n2.i)
|| ((n1.i == n2.i)
&& ((n1.j < n2.j)
|| ((n1.j == n2.j) && (n1.k < n2.k))));
}
bool compare2 (const Node& n1, const Node& n2)
{
return (n1.i || ((n1.i == n2.i) && (n1.j < n2.j))
|| ((n1.i == n2.i) && (n1.j == n2.j) && (n1.k < n2.k));
}
to make compare2 as fast as compare1, whats the name of the optimization?
thx
{
int i;
int j;
int k;
};
bool compare1 (const Node& n1, const Node& n2)
{
return (n1.i < n2.i)
|| ((n1.i == n2.i)
&& ((n1.j < n2.j)
|| ((n1.j == n2.j) && (n1.k < n2.k))));
}
bool compare2 (const Node& n1, const Node& n2)
{
return (n1.i
|| ((n1.i == n2.i) && (n1.j == n2.j) && (n1.k < n2.k));
}
to make compare2 as fast as compare1, whats the name of the optimization?
thx