Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added NonAllocatingMap

...

This doesn't allocate in execution.

Avoid scala.collections.

...

Map. Use NonAllocatingMap (wraps Java

...

Maps) Instead

This is a library instance of the "avoid Option type" problem.

Scala's maps, including mutable HashMap allocates , allocate a Some[T] object for every successful get(key) call.

This is unacceptable overhead for something done so frequently. Use

It is better to use Java's HashMap java.util.Map classes instead, where get(key) returns a value or null, and never allocates anything.

To make this convenient, there is a wrapper NonAllocatingMap:

Code Block
import edu.illinois.ncsa.daffodil.util.NonAllocatingMap

val myMap = new NonAllocatingMap[String, String](new java.util.HashMap[String, String])

This provides the map functionality of the java-provided map class, recast as Scala's types.

Avoid Generic Collections of Unboxed Types

...