Skip to content

Commit

Permalink
Support TLFilter.mSubtract with multiple AddressSets (#3339)
Browse files Browse the repository at this point in the history
Enables filtering out multiple ranges at once.
  • Loading branch information
jerryz123 authored May 5, 2023
1 parent 3f74d79 commit 4110563
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/scala/tilelink/Filter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ object TLFilter
}

// make everything except the intersected address sets visible
def mSubtract(except: AddressSet): ManagerFilter = { m =>
val filtered = m.address.flatMap(_.subtract(except))
def mSubtract(excepts: Seq[AddressSet]): ManagerFilter = { m =>
val filtered = excepts.foldLeft(m.address) { (a,e) => a.flatMap(_.subtract(e)) }
val alignment: BigInt = if (filtered.isEmpty) 0 else filtered.map(_.alignment).min
transferSizeHelper(m, filtered, alignment)
}

def mSubtract(except: AddressSet): ManagerFilter = { m =>
mSubtract(Seq(except))(m)
}

// adjust supported transfer sizes based on filtered intersection
private def transferSizeHelper(m: TLSlaveParameters, filtered: Seq[AddressSet], alignment: BigInt): Option[TLSlaveParameters] = {
val maxTransfer = 1 << 30
Expand Down

0 comments on commit 4110563

Please sign in to comment.