Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated jsonFormatN has unexpectedly large sizeHint #340

Open
cplesner-humio opened this issue Jun 29, 2021 · 1 comment · May be fixed by #343
Open

Generated jsonFormatN has unexpectedly large sizeHint #340

cplesner-humio opened this issue Jun 29, 2021 · 1 comment · May be fixed by #343

Comments

@cplesner-humio
Copy link

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.

@jrudolph
Copy link
Member

Agreed, the whole setup is quite weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants