由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - optimization
相关主题
问个小问题请问这道题怎么解决?
一个关于关键字typename的问题[合集] 一个链表倒转的问题
请教如何自己C++编程牛逼些C++如何实现graph?
question about const reference有人set up过 多个node的Cassandra 么? (转载)
[合集] static const代替define的performance tradeoff在哪里?C++: What is the difference between the two approaches?
const_cast问题Cassandra 里的 partition
function declarationDo the two statements cost the same amount of time?
Re: 请教一道题目tail call strange behavior on cl.exe
相关话题的讨论汇总
话题: node话题: const话题: compare2话题: compare1
进入Programming版参与讨论
1 (共1页)
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)

1 (共1页)
进入Programming版参与讨论
相关主题
tail call strange behavior on cl.exe[合集] static const代替define的performance tradeoff在哪里?
C++ optimization questionconst_cast问题
用C++的写的numerical or optimization solver libraryfunction declaration
Re: VC里面的stl支持是不是很弱?Re: 请教一道题目
问个小问题请问这道题怎么解决?
一个关于关键字typename的问题[合集] 一个链表倒转的问题
请教如何自己C++编程牛逼些C++如何实现graph?
question about const reference有人set up过 多个node的Cassandra 么? (转载)
相关话题的讨论汇总
话题: node话题: const话题: compare2话题: compare1