avatar
C++ optimization question# Programming - 葵花宝典
r*9
1
诚聘勤劳善良,耐心负责,容易相处的阿姨协助家里老人带孩子,简单家务。工作时间
灵活(可全天或半天,每周工作天数可以商量),报酬面议。如有兴趣站内联系。
avatar
T*9
2
同学想要iphone,不知道能不能寄给她
avatar
v*a
3
老公作为dependent提交485, 这种情况下是否要同时申请131和765呢?
如果被拒, 会出行什么情况呢?
OPT8月到期,如果OPT延期在提交485之后做,一定被拒么?
了解的大牛们麻烦指导一下,谢谢谢谢!!!
avatar
r*y
4
苏小明的《幸福不是毛毛雨》这首歌第一次出现在电影里作为插曲是哪部电影?
一直想知道这个答案。我的记忆里,有一部电影出现了郊外雨景,作为带字幕的插曲。
印象里是一部伤痕主题的电影。
已找到的线索:苏小明这首歌1984年出过唱片。
1983年的电影《快乐的单身汉》里这首歌作为非正式的插曲出现过,就是几个女生一边走
一边唱,但是没有字幕,没有情节停断,不算插曲。而且快乐的单身汉已经过了伤痕
时期,所以应该在别的电影作为插曲更早出现过。
avatar
x*c
5
这两天强迫症又找上门来了,昨天和老公吵了架,晚上睡不着,还使劲去听有没有蟋蟀
叫,然后就好象有一点幻听。又好象真的是有蟋蟀叫。现在很害怕。
avatar
j*i
6
Does the gcc compiler optimize the following code?
std::vector v(5);
std::vector::iterator it;
for(it = v.begin(); it != v.end(); it++)
Or is it faster to do this:
std::vector v(5);
std::vector::iterator it;
std::vector::iterator end(v.end());
for(it = v.begin(); it != end; ++it)
Note that the temp variable end, and the preincrement of it.
I was reading Exceptional C++ and it says the second way is faster, but I'm
wondering if the comipler has gotten better since the boo
avatar
r*9
7


【在 r****9 的大作中提到】
: 诚聘勤劳善良,耐心负责,容易相处的阿姨协助家里老人带孩子,简单家务。工作时间
: 灵活(可全天或半天,每周工作天数可以商量),报酬面议。如有兴趣站内联系。

avatar
c*2
8
file I-485, 131 and 765 together.
If your immigration petition is still pending and you are worry 如果被拒,
then don't file his I-485 until your I-130/I-140/I-360... is approved.
avatar
z*o
9
太久远了,那时候家里还没电视看

边走

【在 r****y 的大作中提到】
: 苏小明的《幸福不是毛毛雨》这首歌第一次出现在电影里作为插曲是哪部电影?
: 一直想知道这个答案。我的记忆里,有一部电影出现了郊外雨景,作为带字幕的插曲。
: 印象里是一部伤痕主题的电影。
: 已找到的线索:苏小明这首歌1984年出过唱片。
: 1983年的电影《快乐的单身汉》里这首歌作为非正式的插曲出现过,就是几个女生一边走
: 一边唱,但是没有字幕,没有情节停断,不算插曲。而且快乐的单身汉已经过了伤痕
: 时期,所以应该在别的电影作为插曲更早出现过。

avatar
w*r
10
有在看医生服用药物吗。一般来说症状刚出来的一段时间是治疗的黄金时期,不要拖到
症状很严重或者时间已经很长了再去治疗,那样时间金钱的代价都容易大很多。
MM你现在还是很不错的,对自己的历史和现状都挺清楚,也注意观察自己情绪和身体上
的变化,而且最重要的是你还很愿意去求助于外界的帮助。所以趁着这个不好的苗头才
刚出来,自己精神和体力的状态在大多数时候也都还不错的情况下,赶紧去继续寻求专
业的帮助吧。

【在 x**c 的大作中提到】
: 这两天强迫症又找上门来了,昨天和老公吵了架,晚上睡不着,还使劲去听有没有蟋蟀
: 叫,然后就好象有一点幻听。又好象真的是有蟋蟀叫。现在很害怕。

avatar
B*g
11
The 2 differences both make sense to me.
v.end() is called each loop, which is unnecessary.
++ it does not make a copy of iterator compared to it++.
I don't think compiler should optimize either of those, I could be wrong tho
.
avatar
y*a
12
if you only hoist the end() out of the loop and not the "begin()". I think
oftentimes it doesn't make any difference. The reason the hoisting is good
is because after hoisting, it is easier for the compiler to figure out the
upper-bound of the loop is loop-invariant. but you only know the upper-bound
is constant in the loop but don't know the lower-bound, it really doesn't
help much. Unless you knw both bounds are constant, compiler can do soem
tricks for better performance.

【在 j****i 的大作中提到】
: Does the gcc compiler optimize the following code?
: std::vector v(5);
: std::vector::iterator it;
: for(it = v.begin(); it != v.end(); it++)
: Or is it faster to do this:
: std::vector v(5);
: std::vector::iterator it;
: std::vector::iterator end(v.end());
: for(it = v.begin(); it != end; ++it)
: Note that the temp variable end, and the preincrement of it.

avatar
d*p
13
It is a good habit to do so - expert C++ coders write this way in boost
libraries.
However, most mainstream compilers are able to achieve optimal code in even
the 1st situation. So it does not matter actually.

【在 j****i 的大作中提到】
: Does the gcc compiler optimize the following code?
: std::vector v(5);
: std::vector::iterator it;
: for(it = v.begin(); it != v.end(); it++)
: Or is it faster to do this:
: std::vector v(5);
: std::vector::iterator it;
: std::vector::iterator end(v.end());
: for(it = v.begin(); it != end; ++it)
: Note that the temp variable end, and the preincrement of it.

avatar
y*a
14
compilers can be used to optimize this kind of code. But to say "it doesn't
matter actually" is really far-fetched. The fact is that the compielr can b
e easily confused and then gives up the optimizations that are easy from the
user point of view.
to do that, comipiler has to do good inlining to eliminate the member functi
on calls (many compiler does poor job on that).
oftentimes actually this is the easist thing, it has some benefit because it
eliminates function call overhead. but oftentimes
avatar
d*p
15
Thanks for sharing a lot of insightful info about this issue.
I wish to further put up some stuff which is not guaranteed to be right :-)
Let's narrow down the topic to the vector iterator optimization issue.
My obversation as a user is
1. Withut optimization option turned on, a few compilers (gcc on os x/linux
and CC on solaris) are able to move begin/end iterator access function out
of loop
2. With optimization turned on, the above access functions are inlined
3. The compiler is smart not movi

【在 y***a 的大作中提到】
: compilers can be used to optimize this kind of code. But to say "it doesn't
: matter actually" is really far-fetched. The fact is that the compielr can b
: e easily confused and then gives up the optimizations that are easy from the
: user point of view.
: to do that, comipiler has to do good inlining to eliminate the member functi
: on calls (many compiler does poor job on that).
: oftentimes actually this is the easist thing, it has some benefit because it
: eliminates function call overhead. but oftentimes

avatar
j*i
16
谢谢各位讨论, 受教了.

linux
if
even

【在 d****p 的大作中提到】
: Thanks for sharing a lot of insightful info about this issue.
: I wish to further put up some stuff which is not guaranteed to be right :-)
: Let's narrow down the topic to the vector iterator optimization issue.
: My obversation as a user is
: 1. Withut optimization option turned on, a few compilers (gcc on os x/linux
: and CC on solaris) are able to move begin/end iterator access function out
: of loop
: 2. With optimization turned on, the above access functions are inlined
: 3. The compiler is smart not movi

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。