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.
The code generated for this line,
https://github.com/spray/spray-json/blob/d0008f56bc07f7b5cd446b83184949155d40a7ff/src/main/boilerplate/spray/json/ProductFormatsInstances.scala.template#L31
is expanded to this for instance for
jsonFormat21
: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 useMap.newBuilder
instead?) it would be quite problematic.