stevedlawrence commented on code in PR #1158:
URL: https://github.com/apache/daffodil/pull/1158#discussion_r1488192714
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dpath/NodeInfo.scala:
##########
@@ -198,58 +199,39 @@ object NodeInfo extends Enum {
}
def isError: Boolean = false
- def primType = this
+
+ private lazy val optPrimType_ = Some(this)
+ override def optPrimType: Option[PrimType] = optPrimType_
def fromXMLString(s: String): DataValuePrimitive
override def toString = name
}
- private def getTypeNode(name: String) = {
- val namelc = name.toLowerCase()
- allTypes.find(stn => stn.lcaseName == namelc)
- }
-
- /**
- * For Java API use, we have a very restricted trait api.PrimitiveType
- * mixed into PrimTypeNode, so that we can hand PrimTypeNode as result
- * from methods callable from Java without exposing all of PrimType's
- * implementation.
- * @param name lookup key, case insensitive
- * @return an api.PrimitiveType, or null if there is no type with that name.
- */
- def primitiveTypeFromName(name: String): PrimitiveType = {
- allDFDLTypesLookupTable.get(name)
- }
-
- def isXDerivedFromY(nameX: String, nameY: String): Boolean = {
- if (nameX == nameY) true
- else {
- getTypeNode(nameX) match {
- case Some(stn) => {
- stn.doesParentListContain(nameY)
- }
- case None => false
- }
- }
- }
-
sealed trait Kind extends EnumValueType with PrimTypeView {
def name: String = Misc.getNameFromClass(this)
def parents: Seq[Kind]
def children: Seq[Kind]
- final lazy val isHead: Boolean = parents.isEmpty
- final lazy val lcaseName = name.toLowerCase()
+ /**
+ * The prim type corresponding to this type.
+ * So if this Kind is derived from a PrimType kind, then
+ * this kind should return that prim type object.
+ *
+ * @return None if there is no corresponding prim type.
+ */
+ def optPrimType: Option[PrimType] = None
- final lazy val selfAndAllParents: Set[Kind] = parents.flatMap {
+ private final lazy val lcaseName = name.toLowerCase()
Review Comment:
Yeah, I don't think memory is really an issue in this case. Just something I
try to be aware of. I don't have any numbers, but I feel like we have a lot of
things that are calculated once and stored in a val and never used again just
taking up memory.
--
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]