Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/
Date: Sun, 27 Sep 2015 06:13:33
Message-Id: 1442781688.c86b0416025b4b3f8555295a89c64e233803fef2.vapier@gentoo
1 commit: c86b0416025b4b3f8555295a89c64e233803fef2
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Sun Sep 20 20:41:28 2015 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Sun Sep 20 20:41:28 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=c86b0416
7
8 libsandbox: use memchr to speed up NUL byte search
9
10 Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
11
12 libsandbox/trace.c | 5 ++---
13 1 file changed, 2 insertions(+), 3 deletions(-)
14
15 diff --git a/libsandbox/trace.c b/libsandbox/trace.c
16 index ed05c4d..47d2bdf 100644
17 --- a/libsandbox/trace.c
18 +++ b/libsandbox/trace.c
19 @@ -123,9 +123,8 @@ static char *do_peekstr(unsigned long lptr)
20 strerror(e));
21 }
22
23 - for (i = 0; i < liov.iov_len; ++i)
24 - if (!((char *)liov.iov_base)[i])
25 - return ret;
26 + if (memchr(liov.iov_base, '\0', liov.iov_len) != NULL)
27 + return ret;
28 riov.iov_base += l;
29 riov.iov_len = liov.iov_len = l;
30 len += l;