Skip to content

Commit f2d871c

Browse files
authored
Merge pull request #4326 from danicheg/string-building-from-seq
Make string building a bit more efficient for `NonEmptySeq`
2 parents d347cfa + 374b26d commit f2d871c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/scala/cats/data/NonEmptySeq.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ final class NonEmptySeq[+A] private (val toSeq: Seq[A]) extends AnyVal with NonE
227227
* universal .toString method.
228228
*/
229229
def show[AA >: A](implicit AA: Show[AA]): String =
230-
s"NonEmptySeq(${toSeq.map(Show[AA].show).mkString(", ")})"
230+
s"NonEmptySeq(${toSeq.iterator.map(AA.show).mkString(", ")})"
231231

232232
def length: Int = toSeq.length
233233

234-
override def toString: String = s"NonEmptySeq(${toSeq.map(_.toString).mkString(", ")})"
234+
override def toString: String = s"NonEmptySeq(${toSeq.iterator.map(_.toString).mkString(", ")})"
235235

236236
/**
237237
* Remove duplicates. Duplicates are checked using `Order[_]` instance.

0 commit comments

Comments
 (0)