small speedup in 'nla_strlcpy' in file '\lib\nlattr.c'
Subsystems (2)
PATCH 1/1 small speedup in 'nla_strlcpy' in file '\lib\nlattr.c'
Hi,
I don't know if it worses a patch, but function 'nla_strlcpy' in file '\lib\nlattr.c' could be improved a bit.
There is no need to memset(0) the whole buffer. Only the end of it has to be cleared.
Usually, 'dstsize' is small (most of the time IFNAMSIZ = 16 bytes), so the gain should be real small, if noticeable.
I'm not sure of who to cc: the mail. I've just added Alexey Kuznetsov which is one of the author of the modified file and still in the MAINTAINERS list.
Hope this helps,
Best regards.
lib/nlattr.c 2012-02-06 21:50:43.093750000 +0100 renamed from lib/nlattr.c 2012-02-06 21:40:04.421875000 +0100 +1 -1
@@ -248,8 +248,8 @@ if (dstsize > 0) { size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen; - memset(dst, 0, dstsize); memcpy(dst, src, len); + memset(dst + len, 0, dstsize - len); } return srclen;
Quoted 7 lines · Christophe JAILLET
Hi,
I don't know if it worses a patch, but function '
nla_strlcpy' in file '\lib\nlattr.c' could be improved a bit.
There is no need to memset(0) the whole buffer. Only the end of it has to be cleared.
Quoted 7 lines
Usually, 'dstsize' is small (most of the time IFNAMSIZ = 16 bytes), so the gain should be real small, if noticeable.
I'm not sure of who to cc: the mail. I've just added Alexey Kuznetsov which is one of the author of the modified file and still in the
MAINTAINERSlist.
So if we're not going to notice the speedup, then it's not worth it. Mostly this is only used when people type "ifup eth0" and so a speedup wouldn't even matter. It is used in taskstats so maybe if you did a benchmark and showed that it was faster then that would be a compelling argument. But every patch needs to have a reason to apply it, and "maybe this helps but maybe not" is not good enough salesmanship, you need actual data.
Use the ./scripts/get_maintainer.pl to find which places to send this.
Also your email client mangled the patch so it doesn't apply. Read Documentation/email-clients.txt. Send the patch to yourself first and verify that you can do a "cat raw_email.txt | patch -p1".
regards,
dan carpenter