B4J Library [BANano v3 RC2] More optimizations

alwaysbusy

Expert
Licensed User
See RC1 for the introduction of BANano 3: https://www.b4x.com/android/forum/threads/banano-v3-rc1-the-next-iteration.106460/

Download RC2: http://gorgeousapps.com/BANano3.09RC2_190607.zip

RC2 has greatly improved the 'dead code' system of RC1. The BANano Transpiler will walk the method call tree and try to find even more dead code.

Maybe an example to explain:
Suppose one has a class TestClass

In Main we do this:
B4X:
Sub Test1()
   Log("Test1")
   Test2
End Sub

Sub Test2()
   Log("Test2")
   Test3
End Sub

Sub Test3()
   Log("Test3")
   Dim tstClass As TestClass
   tstClass.Initialize
   tstClass.Test4
End Sub
If Test1 is never been used in your code, then the following will NOT be generated:
B4X:
Test1()
Test2()
Test3()
And although Test3() uses the TestClass, even the TestClass will not be generated
NOTE: the transpiler can not detect a dead loop (yet)
In the above example, if e.g. TestClass would call Test1 in Main, then nothing will be removed, although the loop would never be started in the first place.

I've also simplified the use of ShowWarningDeadCode and RemoveDeadCode (debug/release mode does not play any part in this any more):

Shows what could be removed in the log, but still generates the methods and classes
B4X:
BANano.TranspilerOptions.ShowWarningDeadCode = True
Shows not what could be removed in the log but does not generate the methods and classes
B4X:
BANano.TranspilerOptions.RemoveDeadCode = True
Shows what will be removed in the log and does not generate the methods and classes
B4X:
BANano.TranspilerOptions.ShowWarningDeadCode = True
BANano.TranspilerOptions.RemoveDeadCode = True
Please try it out on your projects and report back with [BANano v3 RC2] in the subject.

Thanks,

Alwaysbusy
 
Last edited:
Top