There are some really handy pragmas that can help you speed up your code a lot if you turn off the things they deal with.
Normally Xojo puts in extra checks to make sure you dont exceed array boundaries and dont overflow the stack on recursive calls. The list is on this page but I’ll repeat a few here
BackgroundTasks Enables or disables auto-yielding to background threads.In addition to the pragma directive, specify True or False. You may place this pragma anywhere within the method to enable or disable background threads as necessary.
BoundsChecking Enables or disables bounds checking.In addition to the pragma directive, specify True or False. You may place this pragma anywhere within the method to enable or disable bounds checking as necessary.
NilObjectChecking Controls whether to automatically check objects for Nil before accessing properties and calling methods. In addition to the pragma directive, specify True or False.
StackOverflowChecking Controls whether to check for stack overflows.In addition to the pragma directive, specify True or False. You may place this pragma anywhere within the method to enable or disable stack overflow checking as necessary.
These 4 can be VERY handy and can improve speed a lot. But, I would suggest ONLY enabling them in release builds AFTER you have debugged everything satisfactorily.
Why ?
Enabling them in a debug build may mean you get odd crashes of your debug builds because none of these checks will be done. And if you have an issue that causes one of these you may get a hard crash of your app being debugged instead of breaking into the debugger where the issue exist.
And there is one more you might need to carefully determine if you want it enabled or not
BreakOnExceptions Used to override the BreakOnExceptions menu item in the IDE. The possible values are: True, False, and Default. You may place this pragma anywhere within the method to enable or disable breaking on exceptions as necessary.
In conjunction with the others if you turn break on exceptions off as well then you can have a horrible time trying to debug.
Often I will use code like
#if debugBuild = false
#pragma BackgroundTasks false
#pragma BoundsChecking false
#pragma NilObjectChecking false
#pragma StackOverflowChecking false
#endif
at the beginning of methods so that during debugging runs I still get the exceptions if I do something that would cause a crash in a release build. Eventually I may also add
#pragma BreakOnExceptions false
outside that group because I have debugged that code well enough and tested whatever exception handling in there I’m happy with it and can ignore any exceptions the code might raise.
Careful out there !