commit:     a13802923b7fef29333c1af7c2b154a83b5bd739
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  5 15:48:26 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan  5 15:59:28 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a1380292

libq/contents: drop expensive checks for newline and tabs

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/contents.c | 16 ++++------------
 1 file 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        - <so...@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;
 

Reply via email to