From: "André Goddard Rosa" <andre.goddard@gmail.com>
To: Frederic Weisbecker <fweisbec@gmail.com>,
laijs@cn.fujitsu.com, mingo@elte.hu, davem@davemloft.net,
akpm@linux-foundation.org, harvey.harrison@gmail.com,
linux list <linux-kernel@vger.kernel.org>
Cc: me <andre.goddard@gmail.com>
Subject: [PATCH v3 7/7] vsprintf: factor out skip_space code in a separate function
Date: Wed, 4 Nov 2009 12:49:14 -0200 [thread overview]
Message-ID: <b8bf37780911040649sb378ccal3d315ff631d21d1d@mail.gmail.com> (raw)
In-Reply-To: <b8bf37780911040625r3fe0d18dx4f74c7be54f5dc3@mail.gmail.com>
From: André Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 3 Nov 2009 11:02:09 -0200
Subject: [PATCH v3 7/7] vsprintf: factor out skip_space code in a
separate function
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It decreases code size:
text data bss dec hex filename
15719 0 8 15727 3d6f lib/vsprintf.o-before
15543 0 8 15551 3cbf lib/vsprintf.o-after
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
---
lib/vsprintf.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index f703fdf..566c947 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1736,6 +1736,13 @@ EXPORT_SYMBOL_GPL(bprintf);
#endif /* CONFIG_BINARY_PRINTF */
+static noinline const char *skip_space(const char *str)
+{
+ while (isspace(*str))
+ ++str;
+ return str;
+}
+
/**
* vsscanf - Unformat a buffer into a list of arguments
* @buf: input buffer
@@ -1757,10 +1764,8 @@ int vsscanf(const char *buf, const char *fmt,
va_list args)
* white space, including none, in the input.
*/
if (isspace(*fmt)) {
- while (isspace(*fmt))
- ++fmt;
- while (isspace(*str))
- ++str;
+ fmt = skip_space(fmt);
+ str = skip_space(str);
}
/* anything that is not a conversion must match exactly */
@@ -1830,8 +1835,7 @@ int vsscanf(const char *buf, const char *fmt,
va_list args)
if (field_width == -1)
field_width = INT_MAX;
/* first, skip leading white space in buffer */
- while (isspace(*str))
- str++;
+ str = skip_space(str);
/* now copy until next white space */
while (*str && !isspace(*str) && field_width--)
@@ -1873,8 +1877,7 @@ int vsscanf(const char *buf, const char *fmt,
va_list args)
/* have some sort of integer conversion.
* first, skip white space in buffer.
*/
- while (isspace(*str))
- str++;
+ str = skip_space(str);
digit = *str;
if (is_sign && digit == '-')
--
1.6.5.2.143.g8cc62.dirty
prev parent reply other threads:[~2009-11-04 14:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-02 17:26 [PATCH v2 " André Goddard Rosa
2009-11-02 19:27 ` Ingo Molnar
2009-11-04 14:25 ` André Goddard Rosa
2009-11-04 14:49 ` André Goddard Rosa [this message]
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=b8bf37780911040649sb378ccal3d315ff631d21d1d@mail.gmail.com \
--to=andre.goddard@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=harvey.harrison@gmail.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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 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®