RFC: New todo for loops
Hello friends!
I have a suggestion for the TODO.
Making loops faster is important. Therefore in the loops we should use pointers instead of arrays.
Example (fs/reiser/file.c:268):
int i; for (i = 0; i < blocks_to_allocate; i++) allocated_blocks[i] = cpu_to_le32(allocated_blocks[i]);
This could be changed to something like:
struct b_blocknr_t *block, *block_last; block_last = &allocated_blocks[allocated_blocks-1]; for (block = allocated_blocks; block <= block_last; block++) *block = cpu_to_le32(*block);
Best Regards,
Daniel Marjamäki
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 2 lines · Daniel Marjam?ki
I have a suggestion for the TODO.
Making loops faster is important. Therefore in the loops we should use pointers instead of arrays.
Do you have evidence this actually produces better code? GCC is pretty smart, you know. And the exammple you posted is harder to understand. BTW, examples using gcc 2.95 don't count; the example has to be for 4.0 or later.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoting Daniel Marjamäki <[email protected]> Sent on Sun, 18 Dec 2005 14:29:53 +0100
Hello,
Quoted 3 lines
I have a suggestion for the TODO.
Making loops faster is important. Therefore in the loops we should use pointers instead of arrays.
can you point data that support your statement?
AMD recommends[1] the opposite.
Regards.
[1] AMD Athlon Processor x86 Code Optimization Guide
http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/22007.pdf
Signature · 9 lines
Ricardo Nabinger Sanchez GNU/Linux #140696 [http://counter.li.org] Slackware Linux + FreeBSD Left to themselves, things tend to go from bad to worse. _______________________________________________ Kernel-janitors mailing list [email protected] https://lists.osdl.org/mailman/listinfo/kernel-janitors
Hi daniel,
i do not like the idea. the code is harder to read and debug, smashing
pointers is easy done. i would not trade that for speed.
SFIK, array[i] is read as *(array+i) with c-compilers. nice example is in "how to write unmaintainable code".
re,
walter
Quoted 16 lines · Daniel Marjamäki
Hello friends!
I have a suggestion for the TODO.
Making loops faster is important. Therefore in the loops we should use pointers instead of arrays.Example (
fs/reiser/file.c:268):int i; for (i = 0; i < blocks_to_allocate; i++) allocated_blocks[i] = cpu_to_le32(allocated_blocks[i]);This could be changed to something like:
struct b_blocknr_t *block, *block_last; block_last = &allocated_blocks[allocated_blocks-1]; for (block = allocated_blocks; block <= block_last; block++) *block = cpu_to_le32(*block);
Quoted 10 lines
Best Regards,
Daniel Marjamäki_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors