Xojo released my 2019 Xojo Developer Conference video on Xojo Design Mistakes on YouTube a few weeks ago at https://www.youtube.com/watch?v=s-FOUxAtK7I&feature=youtu.be.
I liked my alternate title better: Thankfully time travel hasn’t been invented otherwise my future self might come back to murder me because of stupid decisions.
Based on feedback many people found the video to be useful. Hopefully you do too.
The reason I brought this up today is that I’ve spent the last week working on optimizing several large Xojo projects. I’ve identified several areas to look at and if I think it’s it might be worthwhile to look at (after using Instruments and Profiling) I will create a small sample project proving if I can make it more efficient. There are several things that I believed to be true that are not. Here is my initial list:
NthField is Slow: It’s not fast and I wouldn’t recommend using it in a huge loop but it’s not *that* bad. Converting a project that uses it a lot to use Split and then bounds checking just isn’t worth the overhead and hassle of screwing up the code. Plus, it’s one-based whereas Split creates a zero-based array.
String Concatenation is Slow: Again, it’s not exactly speedy in loops but we’re talking ticks if the strings are relatively short. If you use something like this:
dim someString as string = "First line " + _
" second line" + _
" third line"
it is way faster than:
dim someString as string = "First line "
someString = someString + " second line"
someString = someString + " third line"
MBS Functions are always faster: Sometimes MBS *is* faster but not always. Things like picture saving is actually pretty efficient in Xojo. Directory scanning *is* faster using MBS but only in classic API. If you’re using API 2.0 use the FolderItem iterator in a directory and it’s as fast as FileListMBS.
Anyway, that’s a quick and dirty summary of things I’ve learned. Some times it’s good to challenge your assumptions. Happy coding!