In the line below, the method TotalSeconds is called 4 times (to check add a console.log in the implementations):
? CreateObject("roTimeSpan").TotalSeconds().ToStr().Trim()
User @strattonbrazil also reported:
This is also happening for similar chained calls such as:
" 3 ".trim().toInt()
where trim() is called twice. I also found this has always behaved this way and went unnoticed since most of the chained functions had little to no side effects and only their values were used in testing. I also confirmed that this seems specific to function chaining and other cases like 1 + 2 + 3 have the appropriate number of addition operations.
Using the example above, it appears the trim() call is evaluated once in Interpreter.visitDottedGet() and evaluated in Interpreter.visitCall(). While this has some performance concerns, this can certainly introduce more problems when more functions with side effects are introduced. I'll start looking at some options. I'm guessing the Interpreter.visitCall() is the appropriate place to do this evaluation and Interpreter.visitDottedGet() needs to be updated.
In the line below, the method
TotalSeconds
is called 4 times (to check add aconsole.log
in the implementations):? CreateObject("roTimeSpan").TotalSeconds().ToStr().Trim()
User @strattonbrazil also reported: