由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Why Avoid array indexing. Use pointers.
相关主题
what is the most efficient way to trim a string in C++?问个程序问题
[help] how do I improve my coding quality?Perl求助
LISP is better than XML, but worse is better?关于shared pointer的问题
瓶颈在哪儿?谁给解释一下这个c question
JHQ的一道指针题。Randomization of an array
Array in CC++里get array size的问题 (转载)
If using C++, please avoid the use of STL for these questio (转载)C++ Function Pointer Array 的问题
a question of perlcopy constructor 问题
相关话题的讨论汇总
话题: use话题: avoid话题: indexing话题: pointers话题: why
进入Programming版参与讨论
1 (共1页)
e******d
发帖数: 14
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?
g*****g
发帖数: 34805
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?

t****t
发帖数: 6806
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?

g*****g
发帖数: 34805
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: <>
1 (共1页)
进入Programming版参与讨论
相关主题
copy constructor 问题JHQ的一道指针题。
javascriptArray in C
zero-sized array vs pointerIf using C++, please avoid the use of STL for these questio (转载)
array和pointer在作为函数返回时有啥区别 (C)a question of perl
what is the most efficient way to trim a string in C++?问个程序问题
[help] how do I improve my coding quality?Perl求助
LISP is better than XML, but worse is better?关于shared pointer的问题
瓶颈在哪儿?谁给解释一下这个c question
相关话题的讨论汇总
话题: use话题: avoid话题: indexing话题: pointers话题: why