stevedlawrence commented on code in PR #1097:
URL: https://github.com/apache/daffodil/pull/1097#discussion_r1367298136


##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/VariableMap1.scala:
##########
@@ -311,31 +306,33 @@ class VariableMap private (vTable: Map[GlobalQName, 
ArrayBuffer[VariableInstance
    * expression
    */
   def setFirstInstanceInitialValues(): Unit = {
-    vTable.foreach {
-      case (_, variableInstances) => {
-        variableInstances(0).firstInstanceInitialValue = 
variableInstances(0).value
-      }
+    vTable.foreach { variableInstances =>
+      variableInstances.head.firstInstanceInitialValue = 
variableInstances.head.value
     }
   }
 
+  /**
+   * Performance of this is linear in number of variables, this should not be 
used in
+   * performance critical sections.
+   */
   def find(qName: GlobalQName): Option[VariableInstance] = {
-    val optBuf = vTable.get(qName)
-    val variab = {
-      if (optBuf.isDefined)
-        Some(optBuf.get.last)
-      else
-        None
-    }
-    variab
+    getVariableRuntimeData(qName).map { vrd => vTable(vrd.vmapIndex).head }
   }
 
+  /**
+   * Performance of this is linear in number of variables, this should not be 
used in
+   * performance critical sections.
+   */
   def qnames(): Seq[GlobalQName] = {
-    vTable.toSeq.map(_._1)
+    vrds.map { _.globalQName }

Review Comment:
   Yep, will change. Though on second though, maybe one thing to consider is 
that making things a lazy val will keep the memory around. Memory seems to be 
our bottle neck, so maybe for things expected to be accessed rarely or only 
once, it's better to just recalculate it?
   



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to