From: Michael Tokarev <mjt@tls.msk.ru>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [PATCH] 9pfs-local: simplify/optimize local_mapped_attr_path()
Date: Thu, 12 Mar 2015 09:50:29 +0300 [thread overview]
Message-ID: <55013735.2080305@msgid.tls.msk.ru> (raw)
In-Reply-To: <87k2yorc9q.fsf@linux.vnet.ibm.com>
10.03.2015 20:30, Aneesh Kumar K.V wrote:
> Michael Tokarev <mjt@tls.msk.ru> writes:
>
>> Omit one unnecessary memory allocation for components of the path
>> and create the resulting path directly given lengths of the components.
>>
>> This uses (char*) cast because basename() accepts a char* without const,
>> for unknown reason. Maybe it is better to use strrchr(), but I'm not
>> sure for various forms of directory component delimiter.
>
> basename(3) says:
> Both dirname() and basename() may modify the contents of path, so it may
> be desirable to pass a copy when calling one of these functions
The same manpage also says that there are 2 versions of basename(3),
one modifies its arg while another doesn't, and they return different
results in some corner cases. Which one will be used depends on the
compiler flags.
So I think it really is better to open-code it here to have guaranteed
consistent results. I'll send a v2.
[]
> I am not sure whether we really need all these cleanups without really
> fixing anyi specific issue.
This is not a cleanup, it is an optimization: it removes one completely
unnecessary memory allocation. Not in a hottest path but I think it is
worth this small effor anyway.
Thanks,
/mjt
WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] 9pfs-local: simplify/optimize local_mapped_attr_path()
Date: Thu, 12 Mar 2015 09:50:29 +0300 [thread overview]
Message-ID: <55013735.2080305@msgid.tls.msk.ru> (raw)
In-Reply-To: <87k2yorc9q.fsf@linux.vnet.ibm.com>
10.03.2015 20:30, Aneesh Kumar K.V wrote:
> Michael Tokarev <mjt@tls.msk.ru> writes:
>
>> Omit one unnecessary memory allocation for components of the path
>> and create the resulting path directly given lengths of the components.
>>
>> This uses (char*) cast because basename() accepts a char* without const,
>> for unknown reason. Maybe it is better to use strrchr(), but I'm not
>> sure for various forms of directory component delimiter.
>
> basename(3) says:
> Both dirname() and basename() may modify the contents of path, so it may
> be desirable to pass a copy when calling one of these functions
The same manpage also says that there are 2 versions of basename(3),
one modifies its arg while another doesn't, and they return different
results in some corner cases. Which one will be used depends on the
compiler flags.
So I think it really is better to open-code it here to have guaranteed
consistent results. I'll send a v2.
[]
> I am not sure whether we really need all these cleanups without really
> fixing anyi specific issue.
This is not a cleanup, it is an optimization: it removes one completely
unnecessary memory allocation. Not in a hottest path but I think it is
worth this small effor anyway.
Thanks,
/mjt
next prev parent reply other threads:[~2015-03-12 6:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 21:03 [Qemu-trivial] [PATCH] 9pfs-local: simplify/optimize local_mapped_attr_path() Michael Tokarev
2015-03-04 21:03 ` [Qemu-devel] " Michael Tokarev
2015-03-05 1:13 ` [Qemu-trivial] " Fam Zheng
2015-03-05 1:13 ` Fam Zheng
2015-03-10 6:15 ` [Qemu-trivial] " Michael Tokarev
2015-03-10 6:15 ` [Qemu-devel] " Michael Tokarev
2015-03-10 17:30 ` [Qemu-trivial] " Aneesh Kumar K.V
2015-03-10 17:30 ` [Qemu-devel] " Aneesh Kumar K.V
2015-03-12 6:50 ` Michael Tokarev [this message]
2015-03-12 6:50 ` Michael Tokarev
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=55013735.2080305@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/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.