Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1621804
| Path | csiph.com!1.us.feeder.erje.net!2.us.feeder.erje.net!feeder.erje.net!2.eu.feeder.erje.net!news.szaf.org!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | tip-bot for Arnaldo Carvalho de Melo <tipbot@zytor.com> |
| Newsgroups | linux.kernel |
| Subject | [tip:perf/core] perf string: Simplify ltrim() implementation |
| Date | Wed, 12 Apr 2017 07:40:02 +0200 |
| Message-ID | <tvjay-y7-11@gated-at.bofh.it> (permalink) |
| X-Original-To | linux-tip-commits@vger.kernel.org |
| Reply-To | mingo@kernel.org, treeze.taeung@gmail.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, hpa@zytor.com, tglx@linutronix.de, jolsa@kernel.org, acme@redhat.com |
| Git-Commit-ID | ecbe5e10d4ad12dd3da5d9fccd153c529c8c8ce1 |
| X-Mailer | tip-git-log-daemon |
| Robot-ID | <tip-bot.git.kernel.org> |
| Robot-Unsubscribe | Contact <mailto:hpa@kernel.org> to get blacklisted from these emails |
| MIME-Version | 1.0 |
| Content-Transfer-Encoding | 8bit |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Disposition | inline |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 59 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | tglx@linutronix.de, jolsa@kernel.org, acme@redhat.com, mingo@kernel.org, treeze.taeung@gmail.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, hpa@zytor.com |
| X-Original-Date | Tue, 11 Apr 2017 22:37:27 -0700 |
| X-Original-Message-ID | <tip-w3nk0x3pai2vojk2ab6kdvaw@git.kernel.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1621804 |
Show key headers only | View raw
Commit-ID: ecbe5e10d4ad12dd3da5d9fccd153c529c8c8ce1
Gitweb: http://git.kernel.org/tip/ecbe5e10d4ad12dd3da5d9fccd153c529c8c8ce1
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Fri, 7 Apr 2017 12:19:38 -0300
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 11 Apr 2017 15:23:39 -0300
perf string: Simplify ltrim() implementation
We don't need to use strlen(), a var, or check for the end explicitely,
isspace('\0') is false:
[acme@jouet c]$ cat ltrim.c
#include <ctype.h>
#include <stdio.h>
static char *ltrim(char *s)
{
while (isspace(*s))
++s;
return s;
}
int main(void)
{
printf("ltrim(\"\")='%s'\n", ltrim(""));
return 0;
}
[acme@jouet c]$ ./ltrim
ltrim("")=''
[acme@jouet c]$
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Taeung Song <treeze.taeung@gmail.com>
Link: http://lkml.kernel.org/n/tip-w3nk0x3pai2vojk2ab6kdvaw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/string.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index bddca51..e8feb14 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -322,12 +322,8 @@ char *strxfrchar(char *s, char from, char to)
*/
char *ltrim(char *s)
{
- int len = strlen(s);
-
- while (len && isspace(*s)) {
- len--;
+ while (isspace(*s))
s++;
- }
return s;
}
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[tip:perf/core] perf string: Simplify ltrim() implementation tip-bot for Arnaldo Carvalho de Melo <tipbot@zytor.com> - 2017-04-12 07:40 +0200
csiph-web