Skip to content

Commit

Permalink
Skip filtering already-tidied record likes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tarao committed Oct 30, 2023
1 parent aeff3ef commit 3750d4f
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ trait RecordLike[R] {
def iterableOf(r: R): Iterable[(String, Any)]

inline def tidiedIterableOf(r: R): Iterable[(String, Any)] = {
val labels = elemLabels.toSet
iterableOf(r).filter { case (label, _) => labels.contains(label) }
val labels = elemLabels
val it = iterableOf(r)

if (labels.size != it.size) {
val labelSet = labels.toSet
it.filter { case (label, _) => labelSet.contains(label) }
} else {
it
}
}

inline def elemLabels: Seq[String] = RecordLike.seqOfLabels[ElemLabels]
Expand Down

0 comments on commit 3750d4f

Please sign in to comment.