[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH] 9pfs-local: simplify/optimize local_mapped_at

From: Michael Tokarev
Subject: Re: [Qemu-trivial] [PATCH] 9pfs-local: simplify/optimize local_mapped_attr_path()
Date: Thu, 12 Mar 2015 09:50:29 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0

10.03.2015 20:30, Aneesh Kumar K.V wrote:
> Michael Tokarev <address@hidden> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]