ObservationManagerImpl has a optimize method which process the list of includes and excludes and removes redundant clauses. That logic is now also being used in index filtering (
OAK-2599) and is getting duplicated.
Going forward we need to refactor this logic so that both places can use it without copying. Possibly making it part of PathUtils
Michael Dürig Also suggested to further optimize
Also PathFilter#optimise could be further optimised by removing entries that subsume each other (e.g. including /a/b, /a is the same as including (/a.