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_r370361355
 
 

 ##########
 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:
   In theory, this should just be maybeConstant = constValue_. All we are 
trying to do here is a cast from T <: AnyRef : Maybe[AnyRef] -> Maybe[T], which 
is a complete no-op at runtime.
   
   This feels like we should be using DataValuePrimitiveNullable instead of 
either Maybe type. However, I believe I decided that doing so would involve 
refactoring all of out expression classes that used T <: AnyRef, which we 
probably don't want to do.
   
   We can however use the same trick in the Maybe class that I used in the 
DataValue class to do this conversion with 0 runtime overhead.
   
   Essentially, as part of the Maybe class, define an inline function along the 
lines of: unsafeCast[T]:Maybe[T] = (Maybe(this.get))
   
   This worked in the case of DataValues because T was purely a phantom type. 
In the case of Maybe, I think it should be possible to do something similar 
because of type erasure.
   
   

----------------------------------------------------------------
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