* [PATCH] init: Reduce text space by removing a variable.
@ 2009-01-12 5:57 Rakib Mullick
2009-01-12 6:43 ` Sergio Luis
0 siblings, 1 reply; 2+ messages in thread
From: Rakib Mullick @ 2009-01-12 5:57 UTC (permalink / raw)
To: Linux-kernel Mailing List; +Cc: mingo, akpm
Impact: Reduce some text space.
We can carryout the function 'raid_setup' without the variable 'len'
and using a bit compiler optimization. Which also removes 8 bytes of
text space on my x86 system.
Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
--- linux-2.6-orig/init/do_mounts_md.c 2009-01-12 09:53:09.000000000 +0600
+++ linux-2.6/init/do_mounts_md.c 2009-01-12 11:12:39.734543784 +0600
@@ -243,17 +243,17 @@ static void __init md_setup_drive(void)
static int __init raid_setup(char *str)
{
- int len, pos;
+ int pos;
- len = strlen(str) + 1;
pos = 0;
- while (pos < len) {
+ while (pos < strlen(str) + 1) {
char *comma = strchr(str+pos, ',');
int wlen;
if (comma)
wlen = (comma-str)-pos;
- else wlen = (len-1)-pos;
+ else
+ wlen = strlen(str)-pos;
if (!strncmp(str, "noautodetect", wlen))
raid_noautodetect = 1;
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] init: Reduce text space by removing a variable.
2009-01-12 5:57 [PATCH] init: Reduce text space by removing a variable Rakib Mullick
@ 2009-01-12 6:43 ` Sergio Luis
0 siblings, 0 replies; 2+ messages in thread
From: Sergio Luis @ 2009-01-12 6:43 UTC (permalink / raw)
To: Rakib Mullick; +Cc: Linux-kernel Mailing List, mingo, akpm
On Mon, Jan 12, 2009 at 2:57 AM, Rakib Mullick <rakib.mullick@gmail.com> wrote:
> Impact: Reduce some text space.
>
> We can carryout the function 'raid_setup' without the variable 'len'
> and using a bit compiler optimization. Which also removes 8 bytes of
> text space on my x86 system.
>
> Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
>
> --- linux-2.6-orig/init/do_mounts_md.c 2009-01-12 09:53:09.000000000 +0600
> +++ linux-2.6/init/do_mounts_md.c 2009-01-12 11:12:39.734543784 +0600
> @@ -243,17 +243,17 @@ static void __init md_setup_drive(void)
>
> static int __init raid_setup(char *str)
> {
> - int len, pos;
> + int pos;
>
> - len = strlen(str) + 1;
> pos = 0;
>
> - while (pos < len) {
> + while (pos < strlen(str) + 1) {
doesn't calling strlen for every iteration (and in the else statement)
add an unneeded (and unwanted) overhead?
> char *comma = strchr(str+pos, ',');
> int wlen;
> if (comma)
> wlen = (comma-str)-pos;
> - else wlen = (len-1)-pos;
> + else
> + wlen = strlen(str)-pos;
>
> if (!strncmp(str, "noautodetect", wlen))
> raid_noautodetect = 1;
> --
Sergio.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-12 6:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-12 5:57 [PATCH] init: Reduce text space by removing a variable Rakib Mullick
2009-01-12 6:43 ` Sergio Luis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®