Skip to content

Commit

Permalink
fix: linearity in HashMap.erase
Browse files Browse the repository at this point in the history
port of leanprover/lean4#3887 to Std
  • Loading branch information
digama0 committed Apr 12, 2024
1 parent 3298387 commit ec93feb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Std/Data/HashMap/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def erase [BEq α] [Hashable α] (m : Imp α β) (a : α) : Imp α β :=
let ⟨size, buckets⟩ := m
let ⟨i, h⟩ := mkIdx buckets.2 (hash a |>.toUSize)
let bkt := buckets.1[i]
bif bkt.contains a then ⟨size - 1, buckets.update i (bkt.erase a) h⟩ else m
bif bkt.contains a then ⟨size - 1, buckets.update i (bkt.erase a) h⟩ else ⟨size, buckets⟩

/-- Map a function over the values in the map. -/
@[inline] def mapVal (f : α → β → γ) (self : Imp α β) : Imp α γ :=
Expand Down

0 comments on commit ec93feb

Please sign in to comment.