mbeckerle commented on a change in pull request #30: Performance improvements
around FormatInfo change.
URL: https://github.com/apache/incubator-daffodil/pull/30#discussion_r163699710
##########
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
+
def padCharWidthInBits = {
if (maybeFixedWidth.isDefined)
maybeFixedWidth.get
else {
charset match {
Review comment:
Consider rename of identifiers like charset to bitsCharset, and the places
where charsets that are java.nio.charset.Charset to javaCharset.
Consider doing the import things of import java.nio.charset.{Charset =>
JavaCharset} like we do with JBoolean and such.
----------------------------------------------------------------
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