Currently, mongodump has a function dumpFilteredIterToWriter with this section of code:
Because iter.Current isn't valid for long, the code relies on filter to return a copy. This isn't apparent in this code and the filtering code appears to make copies for no apparent reason. I'm not sure if any filter actually modifies oplog entries, but even if so, i think the code would be clearer if we made the copy close to iter.Current:
If we knew that filters never modify, filter could consume iter.Current and return only an error and the copy could be done only if the filter doesn't error.