Make filter return the size of its result.

This helps with various things, but cannot be allocation-optimised in
its current design.