You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "olabusayoT (via GitHub)" <gi...@apache.org> on 2025/04/02 18:34:37 UTC

[PR] Fix unreachable pattern match except null warning [daffodil]

olabusayoT opened a new pull request, #1469:
URL: https://github.com/apache/daffodil/pull/1469

   - fix unused symbols warning
   - fix deprecated do while
   - fix lambda needs paren warning (warning: parentheses are required around the parameter of a lambda)
   - rename enum -> enumVal now that the latter is a keyword
   
   DAFFODIL-2975


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix unreachable pattern match except null warning [daffodil]

Posted by "olabusayoT (via GitHub)" <gi...@apache.org>.
olabusayoT merged PR #1469:
URL: https://github.com/apache/daffodil/pull/1469


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix unreachable pattern match except null warning [daffodil]

Posted by "stevedlawrence (via GitHub)" <gi...@apache.org>.
stevedlawrence commented on code in PR #1469:
URL: https://github.com/apache/daffodil/pull/1469#discussion_r2025454593


##########
daffodil-japi/src/main/scala/org/apache/daffodil/japi/Daffodil.scala:
##########
@@ -94,7 +94,7 @@ object Daffodil {
    * @return new object to compile DFDL schemas
    */
   def compiler(): Compiler = {
-    new Daffodil // silence warning about unused private constructor
+    val _ = new Daffodil // silence warning about unused private constructor

Review Comment:
   If we remove this does it still do the warning about unused private constructor? Maybe this isn't needed anymore?



##########
daffodil-io/src/main/scala/org/apache/daffodil/io/Dump.scala:
##########
@@ -577,18 +574,20 @@ class DataDumper {
         bb.flip()
 
         Assert.invariant(bb.remaining > 0)
-        do {
-          // An overflow means we were able to start to decode at least 1 sequence of characters, but there was either insufficient
-          // space in the output buffer to store said decoded char or there were left over bytes after parsing. If it is
-          // the former, we can proceed and we'll get the left over bytes on the next run, if it was the latter
-          // (as can be the case with decoding a 4 byte character sequence), we will call decode with a larger buffer
-          // until we consume something or the output buffer is at same capacity as input buffer
-          cr = dec.decode(bb, cb, true)
-          nConsumedBytes = bb.position()
-          if (cr.isOverflow && nConsumedBytes == 0) {
-            cb = CharBuffer.allocate(cb.capacity + 1)
-          }
-        } while (cr.isOverflow && nConsumedBytes == 0 && cb.capacity <= bb.capacity)
+        while ({
+          {
+            // An overflow means we were able to start to decode at least 1 sequence of characters, but there was either insufficient
+            // space in the output buffer to store said decoded char or there were left over bytes after parsing. If it is
+            // the former, we can proceed and we'll get the left over bytes on the next run, if it was the latter
+            // (as can be the case with decoding a 4 byte character sequence), we will call decode with a larger buffer
+            // until we consume something or the output buffer is at same capacity as input buffer
+            cr = dec.decode(bb, cb, true)
+            nConsumedBytes = bb.position()
+            if (cr.isOverflow && nConsumedBytes == 0) {
+              cb = CharBuffer.allocate(cb.capacity + 1)
+            }
+          }; cr.isOverflow && nConsumedBytes == 0 && cb.capacity <= bb.capacity
+        }) ()

Review Comment:
   This is pretty hard to follow. I *think* the loop condition still evaluates to true on the first iteration, so can this be converted to a normal while loop by just moving the condition up, e.g.
   
   ```scala
   while (cr.isOverflow && nConsumedBytes == 0 && cb.capacity <= bb.capacity) {
     // normal loop content
     ...
   }
   ```
   It means the first time entering the loop will always evaluate to true, but avoiding that with a do-while isn't that super performance critical--this section of code is never in a hot loop.
   



##########
daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/ModelGroupRuntime1Mixin.scala:
##########
@@ -41,7 +41,6 @@ trait ModelGroupRuntime1Mixin { self: ModelGroup =>
             case t: Term => t.termRuntimeData
           }
         }
-      case _ => Nil

Review Comment:
   Should we remove the match and just do `val res = self.groupmembers.map { ... }`. The match is unnecessary since `this` is always a `ModelGroup`.



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix unreachable pattern match except null warning [daffodil]

Posted by "olabusayoT (via GitHub)" <gi...@apache.org>.
olabusayoT commented on code in PR #1469:
URL: https://github.com/apache/daffodil/pull/1469#discussion_r2029103914


##########
daffodil-japi/src/main/scala/org/apache/daffodil/japi/Daffodil.scala:
##########
@@ -94,7 +94,7 @@ object Daffodil {
    * @return new object to compile DFDL schemas
    */
   def compiler(): Compiler = {
-    new Daffodil // silence warning about unused private constructor
+    val _ = new Daffodil // silence warning about unused private constructor

Review Comment:
   No,, it doesn't complain anymore. I'll remove the lines



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org