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


##########
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:
   This is just in the variable map though? Isn't that a constant data 
structure?
   Either way no biggie. It's documented as linear so all good. 



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