1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-21 23:04:05 +02:00

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.
This commit is contained in:
Werner Almesberger 2010-11-19 22:29:19 -03:00
parent 03c5e4ffe7
commit ed0281f306

View File

@ -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++)