c********e 发帖数: 383 | 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 | t****t 发帖数: 6806 | 2 en...one way is to search gcc manpage. "common subexpression elimination"
sounds like a good name.
【在 c********e 的大作中提到】 : 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)
|
|