stevedlawrence commented on a change in pull request #30: Performance
improvements around FormatInfo change.
URL: https://github.com/apache/incubator-daffodil/pull/30#discussion_r163836129
##########
File path:
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/processors/charset/CharsetUtils.scala
##########
@@ -52,21 +49,29 @@ import edu.illinois.ncsa.daffodil.util.MaybeInt
/**
* Serializable Charset
+ *
+ * java Charset are not serializable, but we need them to be.
+ * So this is serialized as a charset name, and fills in the charset lazily on
+ * first use.
+ *
+ * It's important that this contains a charset, but is not itself a charset.
+ * That way we can't mistake a charset (not serializable) for one of these.
*/
-case class DFDLCharset(val charsetName: String) extends Serializable {
- import java.nio.charset.StandardCharsets
-
+case class DFDLCharset(_initialName: String) extends Serializable {
charset // Force charset to be evaluted to ensure it's valid at compile
time. It's a lazy val so it will be evaluated when de-serialized
- @transient lazy val charset = CharsetUtils.getCharset(charsetName)
+ @transient lazy val charset = CharsetUtils.getCharset(_initialName)
@transient lazy val maybeFixedWidth =
CharsetUtils.maybeEncodingFixedWidth(charset)
+ def charsetName = charset.name
+ def name = charset.name
Review comment:
Can one of these functions be removed, or do they serve different purposes
that an overriding class might change?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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