kernel/filter.c optimizations