General Speed Enhancement Tips/Libs

Blitz3D Forums/Blitz3D Programming/General Speed Enhancement Tips/Libs

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Instead of iterating thru subscripts of an array when comparing/matching data just to see if something exists or not

concatenate data into a large string

For AssyLoop=1 to DataItems
DataString=DataString+Data$+","
Next

Now you can use the Instr() function to determine wether or not the item exists.

How well this works depends on how much data there is, which of course determines the length of the string. Really large strings take longer to process so sometimes you have to break them up into smaller chunks.

It's also possible to match that data to... say, a file position by creating a numerical stripe array and prepopulating the array with relevant positional data. Then when instr() returns a match at whatever position in the assembled string the same position in the stripe array will contain the filing position - so most of the subscripts in the stripe are not used - only the ones at which a match could occur, but despite that inneficiency and being a pain to set up the speed of operation is very much faster than the iterative technique.

It should go without saying that you don't assemble the string for each and every search. Usually these things remain in memory once assembled - so they also need to be maintained if data changes.