Skip to content

Commit 27080dc

Browse files
authored
chore: use FVarIdHashSet in LCNF collectUsed (#8778)
1 parent aef4a29 commit 27080dc

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Lean/Compiler/LCNF/Basic.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def Decl.isTemplateLike (decl : Decl) : CoreM Bool := do
659659
else
660660
return false
661661

662-
private partial def collectType (e : Expr) : FVarIdSetFVarIdSet :=
662+
private partial def collectType (e : Expr) : FVarIdHashSetFVarIdHashSet :=
663663
match e with
664664
| .forallE _ d b _ => collectType b ∘ collectType d
665665
| .lam _ d b _ => collectType b ∘ collectType d
@@ -669,30 +669,30 @@ private partial def collectType (e : Expr) : FVarIdSet → FVarIdSet :=
669669
| .proj .. | .letE .. => unreachable!
670670
| _ => id
671671

672-
private def collectArg (arg : Arg) (s : FVarIdSet) : FVarIdSet :=
672+
private def collectArg (arg : Arg) (s : FVarIdHashSet) : FVarIdHashSet :=
673673
match arg with
674674
| .erased => s
675675
| .fvar fvarId => s.insert fvarId
676676
| .type e => collectType e s
677677

678-
private def collectArgs (args : Array Arg) (s : FVarIdSet) : FVarIdSet :=
678+
private def collectArgs (args : Array Arg) (s : FVarIdHashSet) : FVarIdHashSet :=
679679
args.foldl (init := s) fun s arg => collectArg arg s
680680

681-
private def collectLetValue (e : LetValue) (s : FVarIdSet) : FVarIdSet :=
681+
private def collectLetValue (e : LetValue) (s : FVarIdHashSet) : FVarIdHashSet :=
682682
match e with
683683
| .fvar fvarId args => collectArgs args <| s.insert fvarId
684684
| .const _ _ args => collectArgs args s
685685
| .proj _ _ fvarId => s.insert fvarId
686686
| .lit .. | .erased => s
687687

688-
private partial def collectParams (ps : Array Param) (s : FVarIdSet) : FVarIdSet :=
688+
private partial def collectParams (ps : Array Param) (s : FVarIdHashSet) : FVarIdHashSet :=
689689
ps.foldl (init := s) fun s p => collectType p.type s
690690

691691
mutual
692-
partial def FunDecl.collectUsed (decl : FunDecl) (s : FVarIdSet := {}) : FVarIdSet :=
692+
partial def FunDecl.collectUsed (decl : FunDecl) (s : FVarIdHashSet := {}) : FVarIdHashSet :=
693693
decl.value.collectUsed <| collectParams decl.params <| collectType decl.type s
694694

695-
partial def Code.collectUsed (code : Code) (s : FVarIdSet := {}) : FVarIdSet :=
695+
partial def Code.collectUsed (code : Code) (s : FVarIdHashSet := {}) : FVarIdHashSet :=
696696
match code with
697697
| .let decl k => k.collectUsed <| collectLetValue decl.value <| collectType decl.type s
698698
| .jp decl k | .fun decl k => k.collectUsed <| decl.collectUsed s
@@ -708,7 +708,7 @@ partial def Code.collectUsed (code : Code) (s : FVarIdSet := {}) : FVarIdSet :=
708708
| .jmp fvarId args => collectArgs args <| s.insert fvarId
709709
end
710710

711-
abbrev collectUsedAtExpr (s : FVarIdSet) (e : Expr) : FVarIdSet :=
711+
abbrev collectUsedAtExpr (s : FVarIdHashSet) (e : Expr) : FVarIdHashSet :=
712712
collectType e s
713713

714714
/--

src/Lean/Compiler/LCNF/PullFunDecls.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Local function declaration and join point being pulled.
1717
structure ToPull where
1818
isFun : Bool
1919
decl : FunDecl
20-
used : FVarIdSet
20+
used : FVarIdHashSet
2121
deriving Inhabited
2222

2323
/--

0 commit comments

Comments
 (0)