You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
case class StringMatch(stringTree: Tree) extends OpTree {
final private val autoExpandMaxStringLength = 8
def render(wrapped: Boolean): Tree = {
def unrollUnwrapped(s: String, ix: Int = 0): Tree =
if (ix < s.length) q"""
if (cursorChar == ${s charAt ix}) {
__advance()
${unrollUnwrapped(s, ix + 1)}:Boolean
} else false"""
else q"true"
In that code, the boolean returned by __advance() is not used.
Possible solutions:
(1) We could add some : Unit in the code like this:
case class StringMatch(stringTree: Tree) extends OpTree {
final private val autoExpandMaxStringLength = 8
def render(wrapped: Boolean): Tree = {
def unrollUnwrapped(s: String, ix: Int = 0): Tree =
if (ix < s.length) q"""
if (cursorChar == ${s charAt ix}) {
__advance(): Unit
${unrollUnwrapped(s, ix + 1)}:Boolean
} else false"""
else q"true"
(2) we could change methods like __advance() to return Unit. We would then have to return true in some branches.
I'm wondering if there is a speed difference between having a method returning a value that we don't use?
The fact that we return true allows also some code like q"_root_.java.lang.Character.toLowerCase(cursorChar) == $charTree && __advance()" that shortcuts the __advance() if the first predicate does not match.
The text was updated successfully, but these errors were encountered:
When using the scalac flag
-Wnonunit-statement
, most of the rules emit the following warning:My first quick analysis is coming from:
used like:
In that code, the boolean returned by
__advance()
is not used.Possible solutions:
: Unit
in the code like this:__advance()
to returnUnit
. We would then have to returntrue
in some branches.I'm wondering if there is a speed difference between having a method returning a value that we don't use?
The fact that we return
true
allows also some code likeq"_root_.java.lang.Character.toLowerCase(cursorChar) == $charTree && __advance()"
that shortcuts the__advance()
if the first predicate does not match.The text was updated successfully, but these errors were encountered: