Skip to content

Commit

Permalink
optimization
Browse files Browse the repository at this point in the history
Summary: - if a type alias doesn't have parameters, there is no need to copy-paste its body (`Subst.subst` with an empty substitution will traverse and copy the structure)

Reviewed By: robertoaloi

Differential Revision: D60760134

fbshipit-source-id: 6ee5cf7a304445ace324c35cfb0dc50386552e00
  • Loading branch information
ilya-klyuchnikov authored and facebook-github-bot committed Aug 5, 2024
1 parent 9b8a196 commit f6290ef
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ class Util(pipelineContext: PipelineContext) {
case _ =>
}
val id = Id(remoteId.name, remoteId.arity)
def applyType(decl: TypeDecl): Type = {
val subst = decl.params.zip(args).map { case (VarType(n), ty) => n -> ty }.toMap
Subst.subst(subst, decl.body)
}
def applyType(decl: TypeDecl): Type =
if (id.arity == 0)
decl.body
else {
val subst = decl.params.zip(args).map { case (VarType(n), ty) => n -> ty }.toMap
Subst.subst(subst, decl.body)
}

DbApi
.getType(remoteId.module, id)
Expand Down

0 comments on commit f6290ef

Please sign in to comment.