You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sl...@apache.org on 2023/01/09 20:05:57 UTC
[daffodil] 04/04: Replace match case with reference equality
This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git
commit 4ce0f0caa3c70d76255863dc472d4dc371dc2353
Author: Steve Lawrence <sl...@apache.org>
AuthorDate: Fri Jan 6 08:18:44 2023 -0500
Replace match case with reference equality
Type matching uses instanceof, which has some amount of overhead
compared to straight reference equality. Also reorder the anyURI
condition so the resolve uri condition is first, since it is almost
always going to be false short circuit the condition.
DAFFODIL-2400
---
.../apache/daffodil/infoset/SAXInfosetInputter.scala | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/infoset/SAXInfosetInputter.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/infoset/SAXInfosetInputter.scala
index bc414150f..0ae5ea796 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/infoset/SAXInfosetInputter.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/infoset/SAXInfosetInputter.scala
@@ -96,15 +96,14 @@ class SAXInfosetInputter(
} else {
throw new NonTextFoundInSimpleContentException(getLocalName())
}
- primType match {
- case _: NodeInfo.String.Kind =>
- val remapped = XMLUtils.remapPUAToXMLIllegalCharacters(res)
- remapped
- case _: NodeInfo.AnyURI.Kind if resolveRelativeInfosetBlobURIs && res.nonEmpty =>
- val absUri = resolveRelativeBlobURIs(res)
- absUri
- case _ =>
- res
+ if (primType eq NodeInfo.String) {
+ val remapped = XMLUtils.remapPUAToXMLIllegalCharacters(res)
+ remapped
+ } else if (resolveRelativeInfosetBlobURIs && (primType eq NodeInfo.AnyURI) && res.nonEmpty) {
+ val absUri = resolveRelativeBlobURIs(res)
+ absUri
+ } else {
+ res
}
}