4 ms·
Disclaimed: I know sweet f-a about cryptography, and was expecting 100% of this pdf to go straight over my head. On the other hand, why is the author using "i+
by NAFV_P 12y ago
Disclaimed: I know sweet f-a about cryptography, and was expecting 100% of this pdf to go straight over my head.
On the other hand, why is the author using "i++" in a preamble of a for loop?
- bazzargh 12y agoThat's the style in C-like languages. http://en.wikipedia.org/wiki/For_loop#C.2FC.2B.2B http://en.wikipedia.org/wiki/For_loop#C.2FC.2B.2B ... also used in Java, Javascript, Perl, Php, Bash (and many more I'm sure).
- NAFV_P 12y ago> That's the style in C-like languages. That style is in many cases inefficient. /* summation of successive integers */ /* don't worry, this should not cause overflow in a 32-bit signed integer type */ volatile int i=0; int j=0; for( ; i<65536; i++) /* ++i is better suited to this scenario */ j+=i; Being declared as volatile, the compiler will not attempt to optimise the for loop and change the code that increments i in the preamble from postfix to prefix. I will admit this is an extreme example, but I often see examples on the internet of simple for loops written in this manner when prefix is more suitable and simpler for the cpu to execute. Postfix increments of integer types involve making a local copy (y) of the variable to increment (x), then incrementing x and returning y. Prefix increments merely involve incrementing x. The former method is rather expensive. On the other hand, it would make sense to use postfix on something like [0]. [0] http://en.wikipedia.org/wiki/Duff's_device#Original_version http://en.wikipedia.org/wiki/Duff's_device#Original_version
- pbsd 12y agoHave you actually tried your example? Even at -O0, it results in the exact same code: http://goo.gl/kDEFnU http://goo.gl/kDEFnU