A large speedup could be obtainable by writing the particle type in all the records
See branch assume_full_mask
. This assumes that all the records contain all the masks all the time, but this assumption could be easily removed.
In order to properly implement it, it would require to implement a way to obtain the particle type directly from a given record. The field particle IDs should also be available.