mbeckerle commented on a change in pull request #259: Incremental progress on 
schema compilation space/speed issue.
URL: https://github.com/apache/incubator-daffodil/pull/259#discussion_r301241739
 
 

 ##########
 File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/dsom/CompiledExpression1.scala
 ##########
 @@ -240,57 +240,44 @@ class DPathCompileInfo(
    * Then we move outward to the enclosing element - and if there
    * isn't one we return None. (Which most likely will lead to an SDE.)
    */
-  final def enclosingElementCompileInfo: Option[DPathElementCompileInfo] = {
-    val eci = this.elementCompileInfo
-    eci match {
-      case None => None
-      case Some(eci) => {
-        val eci2 = eci.parent
-        eci2 match {
-          case None => None
-          case Some(ci) => {
-            val res = ci.elementCompileInfo
-            res
-          }
-        }
-      }
-    }
+  final def enclosingElementCompileInfos: Seq[DPathElementCompileInfo] = {
+    val eci = elementCompileInfos.flatMap { _.parents }
+    val res = eci.flatMap { _.elementCompileInfos }
+    res
   }
 
   /**
    * The contract here supports the semantics of "." in paths.
    *
    * If this is an element we're done. If not we move outward
    * until we reach an enclosing element.
+   *
+   * This is used because paths refer to elements, so we have to
+   * walk upward until we get elements. At that point we can
+   * then navigate element to element.
    */
-  final lazy val elementCompileInfo: Option[DPathElementCompileInfo] = this 
match {
-    case e: DPathElementCompileInfo => Some(e)
+  final lazy val elementCompileInfos: Seq[DPathElementCompileInfo] = this 
match {
+    case e: DPathElementCompileInfo => Seq(e)
     case d: DPathCompileInfo => {
-      val eci = d.parent
-      eci match {
-        case None => None
-        case Some(ci) => {
-          val res = ci.elementCompileInfo
-          res
-        }
-      }
+      val eci = d.parents
+      eci flatMap { ci => ci.elementCompileInfos }
     }
   }
 
   /**
    * relative path - relative to enclosing element's path
    * which by definition must be a prefix of this object's path.
    */
-  final def relativePath: String = {
-    val rel = elementCompileInfo.map {
-      parentInfo =>
-        Assert.invariant(path.startsWith(parentInfo.path))
-        path.substring(parentInfo.path.length)
-    }
-    val s = rel.getOrElse(path)
-    val res = if (s.startsWith("::")) s.substring("::".length) else s
-    res
-  }
+  //  final def relativePath: String = {
 
 Review comment:
   remove

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