Applying functions for speed optimization

General FreeBASIC programming questions.
Aethelstan
Posts: 19
Joined: Feb 22, 2017 18:34

Re: Applying functions for speed optimization

Post by Aethelstan »

If there is no particular reason for passing arrays to functions, I would avoid it completely and make them global, like that:

Code: Select all

dim Shared as integer array(1000)

function m_fastbigrams( l as integer, s as integer) as integer	'<== no array passed as parameter
This array is filled with data in main program, procedure only needs to get it's data upper bounds (variable l in your example).
I think that you could also pass an array pointer instead of whole array if it would be really necessary, but I'm not familiar with that method; maybe someone else could explain it here.
Post Reply