From ed0281f306bdc30a018eeb6e6723148c514ec1dc Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 19 Nov 2010 22:29:19 -0300 Subject: [PATCH] qpkg/gobble.c (EXPECT): added variant that just skips over expected text If the package database is sane, then we don't need to check that all the field names match what we expect. This saves a few more CPU cycles. However, if anything goes wrong, the consequences may be unpleasant. Thus, we default to the slow but safe approach. --- qpkg/gobble.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qpkg/gobble.c b/qpkg/gobble.c index 6856219..6407c60 100644 --- a/qpkg/gobble.c +++ b/qpkg/gobble.c @@ -15,16 +15,24 @@ #define CHARS_AFTER_ERROR 20 +#ifdef BREAKNECK_SPEED + +#define EXPECT(s) do { buf += sizeof(s)-1; } while (0) + +#else /* !BREAKNECK_SPEED */ + #define EXPECT(s) \ do { \ if (end-buf < sizeof(s)-1) \ - FAIL; \ + FAIL; \ if (memcmp(buf, s, sizeof(s)-1)) \ FAIL; \ buf += sizeof(s)-1; \ } \ while (0) +#endif + #define NEXT (buf == end ? '?' : *buf++)