mbeckerle commented on a change in pull request #30: Performance improvements
around FormatInfo change.
URL: https://github.com/apache/incubator-daffodil/pull/30#discussion_r163985070
##########
File path:
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/Evaluatable.scala
##########
@@ -336,30 +292,40 @@ abstract class Evaluatable[+T <: AnyRef](protected val
rd: RuntimeData, qNameArg
}
}
- private var constValue_ : Option[AnyRef] = None
- protected def constValue = constValue_.asInstanceOf[Option[T]]
+ private var constValue_ : Maybe[AnyRef] = Nope
- def optConstant = {
- ensureCompiled
- constValue
- }
+ /**
+ * Preferred for use in the runtime.
+ */
+ @inline final def maybeConstant = constValue_.asInstanceOf[Maybe[T]]
+ @inline final def isConstant = constValue_.isDefined
+ @inline final def constValue = maybeConstant.get
- def isConstant = {
- ensureCompiled
- constValue.isDefined
+ /**
+ * Schema compiler wants to use map call, so we need a scala option type
+ * for that. So this variant supplies that.
+ */
+ @inline final def optConstant = {
+ maybeConstant.toScalaOption
}
/**
* Compile an Ev to see if it is a constant at compilation time.
* This is determined by actually evaluating it, passing a special
CompileState
* that errors out when data access to runtime-valued data is attempted.
*/
- final override def compile(state: CompileState) = {
- val y = super.compile(state)
+ final def compile(state: CompileState): Maybe[T] = {
+ val y = compile1(state)
Review comment:
Renamed to compileTimeEvaluate() which really does say what happens in that
method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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