bsloane1650 commented on a change in pull request #316: Assortment of changes 
to improve performance
URL: https://github.com/apache/incubator-daffodil/pull/316#discussion_r370705004
 
 

 ##########
 File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/Evaluatable.scala
 ##########
 @@ -285,7 +285,17 @@ abstract class Evaluatable[+T <: AnyRef](protected val 
ci: DPathCompileInfo, qNa
   /**
    * Preferred for use in the runtime.
    */
-  @inline final def maybeConstant = constValue_.asInstanceOf[Maybe[T]]
+  @inline final def maybeConstant = {
 
 Review comment:
   The insight is that T and AnyRef are the same thing, so it should be 
possible to cast from Maybe[AnyRef] to Maybe[T] without overhead.
   
   In DataValue.unsafeFromMaybeAnyRef, there is added complexity since the 
actual function is:
   
   ```
   null -> DataValue.empty
   value -> value
   ```
   
   In the case of Maybe, we have:
   
   ```
   null -> null
   value -> value
   ```
   
   which can be treated as a single case.
   
   The analogous situation in DataValues, would be getNullablePrimitive:
   
   ``` @inline def getNullablePrimitive:DataValue.DataValuePrimitiveNullable = 
new DataValue(v) ```
   
   which does the cast without doing anything.
   
   Having said that, we are only talking about 1 conditional statement, so it 
probably isn't worth spending too much time on this.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to