stevedlawrence commented on a change in pull request #316: Assortment of
changes to improve performance
URL: https://github.com/apache/incubator-daffodil/pull/316#discussion_r370360955
##########
File path:
daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/DelimiterUnparsers.scala
##########
@@ -56,7 +56,7 @@ class DelimiterTextUnparser(override val context:
TermRuntimeData, delimiterType
else localDelimNode.terminator
}
- if (delimDFAs.isEmpty) Assert.invariantFailed("Expected a delimiter of
type " + delimiterType + " on the stack, but was not found.")
+ if (delimDFAs.length == 0) Assert.invariantFailed("Expected a delimiter of
type " + delimiterType + " on the stack, but was not found.")
Review comment:
Yep, there's an actual advantage here. delimDFAs is type ``Array[T]``. Scala
will normally do the right than and represent this in byte code as a java
array[]. All is good. However, if you try to use any functions that are
normally Scala Sequence-y type things (e.g. isEmpty, .size), Scala will
implicitly wrap the array in an ``ArrayOps``. This gives you all the nice
scala-y stuff that were used to. However, this means we are allocating an
ArrayOps just do figure out if the array is empty or not. While it's convenient
and looks nice, it added does add allocations. I'm not sure if it really
affected the performance, but this was called a ton, and made the profiling
very noise, so this at least helps to get rid of some of that noise.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services