Skip to content

Commit

Permalink
Call Map.concat instead of Iterable.concat.
Browse files Browse the repository at this point in the history
Iterable.concat is extremely slower than Map.concat.  Note that the
latter does not override the former.  We have to explicitly call the
latter.
  • Loading branch information
tarao committed Oct 10, 2023
1 parent 6b16811 commit e0b48d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ object Macros {
case '[tpe] =>
evidenceOf[typing.Concat[R, tpe]] match {
case '{ ${ _ }: typing.Concat[R, tpe] { type Out = returnType } } =>
newMapRecord[returnType]('{ ${ rec } ++ ${ Expr.ofSeq(fields) } })
newMapRecord[returnType]('{
${ rec }.toMap.concat(${ Expr.ofSeq(fields) })
})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ object Record {
other: R2,
)(using typing.Concat.Aux[R, R2, RR]): RR = withPotentialTypingError {
newMapRecord[RR](
record.__iterable ++ summon[RecordLike[R2]].tidiedIterableOf(other),
record
.__iterable
.toMap
.concat(summon[RecordLike[R2]].tidiedIterableOf(other)),
)
}

Expand Down

0 comments on commit e0b48d1

Please sign in to comment.