Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
3.0.0
-
None
Description
Scala 2.12 supports Single Abstract Method (SAM) syntax like Java 8. Using this would lightly simplify a lot of code where we define an anonymous inner class. E.g.
private[sql] val ordering = new Ordering[InternalType] { override def compare(x: Array[Byte], y: Array[Byte]): Int = { TypeUtils.compareBinary(x, y) } }
becomes:
private[sql] val ordering = (x: Array[Byte], y: Array[Byte]) => TypeUtils.compareBinary(x, y)
There's a small improvement to readability, and probably a tiny benefit at runtime as these become lambdas in the JVM, not inner classes that have to be compiled and instantiated. (There's also a very small reduction in the chance that those inner classes are accidentally holding references to things we don't want them to.)
Attachments
Issue Links
- links to