Skip to content

Commit

Permalink
Remove to strct condition, debug mode compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Nov 21, 2019
1 parent c19e12e commit 9feb8d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Binary file removed weave/channels/channels_mpsc_unbounded
Binary file not shown.
6 changes: 4 additions & 2 deletions weave/datatypes/sparsesets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ func contains*(s: SparseSet, n: SomeInteger): bool {.inline.} =

func incl*(s: var SparseSet, n: SomeInteger) {.inline.} =
preCondition: n < Empty
preCondition: n notin s

if n in s: return

preCondition: s.len < s.capacity

s.indices[n] = s.len
Expand All @@ -101,7 +103,7 @@ func peek*(s: SparseSet): int32 {.inline.} =
int32 s.values[s.len - 1]

func excl*(s: var SparseSet, n: SomeInteger) {.inline.} =
preCondition: n in s
if n notin s: return

# We do constant time deletion by replacing the deleted
# integer by the last value in the array of values
Expand Down
3 changes: 1 addition & 2 deletions weave/targets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ proc markIdle(victims: var SparseSet, workerID: WorkerID) =
# Invalid worker ID (parent of root or out-of-bound child)
return

preCondition: workerID notin victims

let maxID = workforce() - 1
if workerID < workforce():
# mark children
victims.excl(workerID)
markIdle(victims, left(workerID, maxID))
markIdle(victims, right(workerID, maxID))

Expand Down

0 comments on commit 9feb8d0

Please sign in to comment.