Skip to content

Generated jsonFormatN has unexpectedly large sizeHint  #340

@cpha-trifork

Description

@cpha-trifork

The code generated for this line,

is expanded to this for instance for jsonFormat21:

    def write(p: T) = {
      val fields = new collection.mutable.ListBuffer[(String, JsValue)]
      fields.sizeHint(20 * 21)
      fields ++= productElement2Field[P1](fieldName1, p, 0)
      ...

I don't think ListBuffer actually uses the size hint so it's not that bad but if you ever switched to a different kind of collection that did (and actually side note: why not use Map.newBuilder instead?) it would be quite problematic.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions