diff options
author | Fabian Groffen <grobian@gentoo.org> | 2020-01-05 16:48:26 +0100 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2020-01-05 16:59:28 +0100 |
commit | a13802923b7fef29333c1af7c2b154a83b5bd739 (patch) | |
tree | 0acfd727425f307014e23095bc683c448c1373f1 | |
parent | libq/tree: distinguish between empty and absent file in tree_pkg_meta_get (diff) | |
download | portage-utils-a1380292.tar.gz portage-utils-a1380292.tar.bz2 portage-utils-a1380292.zip |
libq/contents: drop expensive checks for newline and tabs
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r-- | libq/contents.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/libq/contents.c b/libq/contents.c index 3e719a6..7f4351d 100644 --- a/libq/contents.c +++ b/libq/contents.c @@ -1,5 +1,5 @@ /* - * Copyright 2005-2019 Gentoo Foundation + * Copyright 2005-2020 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 * * Copyright 2005-2008 Ned Ludd - <solar@gentoo.org> @@ -24,22 +24,14 @@ contents_parse_line(char *line) static contents_entry e; char *p; - if (!line || !*line || *line == '\n') + if (line == NULL || *line == '\0' || *line == '\n') return NULL; /* chop trailing newline */ - if ((p = strrchr(line, '\n')) != NULL) + p = &line[strlen(line) - 1]; + if (*p == '\n') *p = '\0'; - /* ferringb wants to break portage/vdb by using tabs vs spaces - * so filenames can have lame ass spaces in them.. - * (I smell Windows near by) - * Anyway we just convert that crap to a space so we can still - * parse quickly */ - p = line; - while ((p = strchr(p, '\t')) != NULL) - *p = ' '; - memset(&e, 0x00, sizeof(e)); e._data = line; |