* [KJ] RFC: New todo for loops
@ 2005-12-18 13:29 Daniel Marjamäki
2005-12-18 13:44 ` Matthew Wilcox
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Marjamäki @ 2005-12-18 13:29 UTC (permalink / raw)
To: kernel-janitors
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
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [KJ] RFC: New todo for loops
2005-12-18 13:29 [KJ] RFC: New todo for loops Daniel Marjamäki
@ 2005-12-18 13:44 ` Matthew Wilcox
2005-12-18 14:08 ` Ricardo Nabinger Sanchez
2005-12-18 14:34 ` walter harms
2 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2005-12-18 13:44 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 429 bytes --]
On Sun, Dec 18, 2005 at 02:29:53PM +0100, Daniel Marjam?ki wrote:
> 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.
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [KJ] RFC: New todo for loops
2005-12-18 13:29 [KJ] RFC: New todo for loops Daniel Marjamäki
2005-12-18 13:44 ` Matthew Wilcox
@ 2005-12-18 14:08 ` Ricardo Nabinger Sanchez
2005-12-18 14:34 ` walter harms
2 siblings, 0 replies; 4+ messages in thread
From: Ricardo Nabinger Sanchez @ 2005-12-18 14:08 UTC (permalink / raw)
To: kernel-janitors
Quoting Daniel Marjamäki <daniel.marjamaki@comhem.se>
Sent on Sun, 18 Dec 2005 14:29:53 +0100
Hello,
> 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
--
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
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [KJ] RFC: New todo for loops
2005-12-18 13:29 [KJ] RFC: New todo for loops Daniel Marjamäki
2005-12-18 13:44 ` Matthew Wilcox
2005-12-18 14:08 ` Ricardo Nabinger Sanchez
@ 2005-12-18 14:34 ` walter harms
2 siblings, 0 replies; 4+ messages in thread
From: walter harms @ 2005-12-18 14:34 UTC (permalink / raw)
To: 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
Daniel Marjamäki wrote:
> 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
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors
>
>
>
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-12-18 14:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-18 13:29 [KJ] RFC: New todo for loops Daniel Marjamäki
2005-12-18 13:44 ` Matthew Wilcox
2005-12-18 14:08 ` Ricardo Nabinger Sanchez
2005-12-18 14:34 ` walter harms
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.