sapling/lib/dag
Jun Wu e7a89e8c45 spanset: make Span a dedicated type
Summary:
Use a dedicated Span type so we can enforce reverse ordering and `start <= end`
directly on the Span structure.

The constructor of `SpanSet` becomes more expensive because it recreates the
`Vec`, and sorts it. Practically, hopefully it's fine. Internal logic like union will
not use that constructor.

Some comments and tweaks have been made to make the code easier to read.

There are some performance changes, though:

Before:

  intersection                    5.030 ms
  union                           5.920 ms
  difference                      4.804 ms

After:

  intersection                    6.036 ms
  union                           5.426 ms
  difference                      4.710 ms

`intersection` becomes slower, while `union` and `difference` become a bit faster.
Hopefully the regression is within the acceptable range.

Reviewed By: sfilipco

Differential Revision: D15023651

fbshipit-source-id: ea7845d5d20faf204cfb85c66fc3bd6e25c9fc0c
2019-04-25 17:05:11 -07:00
..
benches spanset: make Span a dedicated type 2019-04-25 17:05:11 -07:00
src spanset: make Span a dedicated type 2019-04-25 17:05:11 -07:00
Cargo.toml spanset: add a benchmark of set operations 2019-04-25 17:05:10 -07:00