From: walter harms <wharms@bfs.de>
To: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Joe Perches <joe@perches.com>,
Anton Altaparmakov <aia21@cam.ac.uk>,
John Daiker <daikerjohn@gmail.com>,
kernel-janitors@vger.kernel.org, aia21@cantab.net,
linux-ntfs-dev@lists.sourceforge.net,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] NTFS: Change string pointers to string constants.
Date: Wed, 09 Dec 2009 15:07:50 +0000 [thread overview]
Message-ID: <4B1FBD46.1050204@bfs.de> (raw)
In-Reply-To: <20091209145846.GA3562@joi.lan>
Marcin Slusarz schrieb:
> On Mon, Dec 07, 2009 at 05:47:13PM -0800, Joe Perches wrote:
>> On Tue, 2009-12-08 at 00:57 +0000, Anton Altaparmakov wrote:
>>> Can you please explain the rational for making this change?
>> Perhaps it's not worth much, but it saves a pointer reference.
>>
>> $ cat pointer.c
>> #include <string.h>
>> #include <stdio.h>
>>
>> int main (int argc, char** argv)
>> {
>> static const char *foo = "abcdefg";
>> printf("%s\n", foo);
>> return 0;
>> }
>>
>> $ gcc -c pointer.c
>> $ size pointer.o
>> text data bss dec hex filename
>> 37 4 0 41 29 pointer.o
>>
>> $ cat reference.c
>> #include <string.h>
>> #include <stdio.h>
>>
>> int main (int argc, char** argv)
>> {
>> static const char foo[] = "abcdefg";
>> printf("%s\n", foo);
>> return 0;
>> }
>>
>> $ gcc -c reference.c
>> $ size reference.o
>> text data bss dec hex filename
>> 36 0 0 36 24 reference.o
>
> Yeah, for static variables it's better. But for automatic variables
> it's worse, because it now has to do a copy at runtime.
> And the patch changes both types.
>
> $ size pointer.o reference.o
> text data bss dec hex filename
> 101 8 0 109 6d pointer.o
> 96 0 0 96 60 reference.o
>
> $ size pointer-nonstatic.o reference-nonstatic.o
> text data bss dec hex filename
> 106 0 0 106 6a pointer-nonstatic.o
> 109 0 0 109 6d reference-nonstatic.o
> --
nobody should spend to much time on this. gcc <what ever next version>
will have different results. It is better to spend time improving
the compiler and make it generate shorter/faster code.
just my 2 cents,
wh
WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Joe Perches <joe@perches.com>,
Anton Altaparmakov <aia21@cam.ac.uk>,
John Daiker <daikerjohn@gmail.com>,
kernel-janitors@vger.kernel.org, aia21@cantab.net,
linux-ntfs-dev@lists.sourceforge.net,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] NTFS: Change string pointers to string constants.
Date: Wed, 09 Dec 2009 16:07:50 +0100 [thread overview]
Message-ID: <4B1FBD46.1050204@bfs.de> (raw)
In-Reply-To: <20091209145846.GA3562@joi.lan>
Marcin Slusarz schrieb:
> On Mon, Dec 07, 2009 at 05:47:13PM -0800, Joe Perches wrote:
>> On Tue, 2009-12-08 at 00:57 +0000, Anton Altaparmakov wrote:
>>> Can you please explain the rational for making this change?
>> Perhaps it's not worth much, but it saves a pointer reference.
>>
>> $ cat pointer.c
>> #include <string.h>
>> #include <stdio.h>
>>
>> int main (int argc, char** argv)
>> {
>> static const char *foo = "abcdefg";
>> printf("%s\n", foo);
>> return 0;
>> }
>>
>> $ gcc -c pointer.c
>> $ size pointer.o
>> text data bss dec hex filename
>> 37 4 0 41 29 pointer.o
>>
>> $ cat reference.c
>> #include <string.h>
>> #include <stdio.h>
>>
>> int main (int argc, char** argv)
>> {
>> static const char foo[] = "abcdefg";
>> printf("%s\n", foo);
>> return 0;
>> }
>>
>> $ gcc -c reference.c
>> $ size reference.o
>> text data bss dec hex filename
>> 36 0 0 36 24 reference.o
>
> Yeah, for static variables it's better. But for automatic variables
> it's worse, because it now has to do a copy at runtime.
> And the patch changes both types.
>
> $ size pointer.o reference.o
> text data bss dec hex filename
> 101 8 0 109 6d pointer.o
> 96 0 0 96 60 reference.o
>
> $ size pointer-nonstatic.o reference-nonstatic.o
> text data bss dec hex filename
> 106 0 0 106 6a pointer-nonstatic.o
> 109 0 0 109 6d reference-nonstatic.o
> --
nobody should spend to much time on this. gcc <what ever next version>
will have different results. It is better to spend time improving
the compiler and make it generate shorter/faster code.
just my 2 cents,
wh
next prev parent reply other threads:[~2009-12-09 15:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-03 2:53 [PATCH] NTFS: Change string pointers to string constants John Daiker
2009-12-03 2:53 ` John Daiker
2009-12-08 0:57 ` Anton Altaparmakov
2009-12-08 0:57 ` Anton Altaparmakov
2009-12-08 1:47 ` Joe Perches
2009-12-08 1:47 ` Joe Perches
2009-12-08 19:16 ` John Daiker
2009-12-08 19:16 ` John Daiker
2009-12-09 14:59 ` Marcin Slusarz
2009-12-09 14:59 ` Marcin Slusarz
2009-12-09 15:07 ` walter harms [this message]
2009-12-09 15:07 ` walter harms
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B1FBD46.1050204@bfs.de \
--to=wharms@bfs.de \
--cc=aia21@cam.ac.uk \
--cc=aia21@cantab.net \
--cc=daikerjohn@gmail.com \
--cc=joe@perches.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ntfs-dev@lists.sourceforge.net \
--cc=marcin.slusarz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.