dect
/
libpcap
Archived
13
0
Fork 0

Optimize out "jset #0" (always false) and "jset #ffffffff" (always true).

This commit is contained in:
fenner 2001-11-12 22:02:50 +00:00
parent 1c20fa1fee
commit cae054001c
1 changed files with 11 additions and 1 deletions

View File

@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.69 2001-11-12 21:57:06 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.70 2001-11-12 22:02:50 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -823,6 +823,16 @@ opt_peep(b)
done = 0;
opt_not(b);
}
/*
* jset #0 -> never
* jset #ffffffff -> always
*/
if (b->s.code == (BPF_JMP|BPF_K|BPF_JSET)) {
if (b->s.k == 0)
JT(b) = JF(b);
if (b->s.k == 0xffffffff)
JF(b) = JT(b);
}
/*
* If the accumulator is a known constant, we can compute the
* comparison result.