Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Motivation: `sum(where:)` defined its complexity of O(n) while the implementation was O(2n). An implementation is possible to do the filtering inlined. In addition, all overloads of `sum` should be inlinable to provide the compiler the most opportunity to optimize these style of calculations. Modifications: - Add `@inlinable` attributes to both overloads of `sum` - Update `sum(where:)` to assert the `isIncluded` predicate and calculating the sum in a single traversal Result: Calculating a sum of currencies that pass a filter predicate should be twice as fast.
- Loading branch information