Redian新闻
>
Why Avoid array indexing. Use pointers.
avatar
Why Avoid array indexing. Use pointers.# Programming - 葵花宝典
e*d
1
Code optimization 有这么一条 Avoid array indexing, Use pointers. 为什么呢?不需要再算地址了?
还有 Use int (natural word-size of the processor) to store flags rather than char or short。就因为alignment?
avatar
g*g
2
I would say leave these stuff to smart compiler,
clean and readable code is more important in 99.9% of case.

?不需要再算地址了?
than char or short。就因为alignment?

【在 e******d 的大作中提到】
: Code optimization 有这么一条 Avoid array indexing, Use pointers. 为什么呢?不需要再算地址了?
: 还有 Use int (natural word-size of the processor) to store flags rather than char or short。就因为alignment?

avatar
t*t
3
context: <>

【在 g*****g 的大作中提到】
: I would say leave these stuff to smart compiler,
: clean and readable code is more important in 99.9% of case.
:
: ?不需要再算地址了?
: than char or short。就因为alignment?

avatar
g*g
4
That's exactly my point, this level of optimization should be done
by compiler. In code optimization context, it's about the 80-20 rule,
find out the bottleneck, use the better algorithm if there's any,
cut the redudant code, move out what doesn't have to be in loop.
99.9% cases these are more than enough. And in case they are not,
those little dirty tricks are not good enough to help either.

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