I once read in a BASIC documentation that it was to locate SUB routines at the beginning of the code, since when the interpreter searches for a ref, it always starts at the beginning, and then is more likely to find the ref quicker.
Does the code in SB obeys to this behavior ? Then do i need to place DEF - ENDDEFs at the beginning of the code ? And the ones more called at the very top ?
Is it faster to place user def functions at the beginning of the code ?
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Is it faster to place user def functions at the beginning of the code ?
No, for sB there is no difference where DEF is placed.
Re: Is it faster to place user def functions at the beginning of the code ?
Any other tips:hints to "squeze" smart Basis
concerning speed...?
- would short variable names help?
- would avoiding use of struct.variables
in main loops help ?
- For example using sprites only with
no graphics command at all (not even
graphics clear) makes the code fast...
concerning speed...?
- would short variable names help?
- would avoiding use of struct.variables
in main loops help ?
- For example using sprites only with
no graphics command at all (not even
graphics clear) makes the code fast...
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Is it faster to place user def functions at the beginning of the code ?
There is no difference what names are used. Also there is no difference whether scope variables are used or not.
Sprites may work faster than main graphics screen because sprite is a small graphics screen, and main graphics screen is much bigger in size.
sB is tuned internally to work fast. Before running it performs code checking and finds all labels and DEFs, so when running it already knows where they are located - that is why it does not matter where they are placed in program.
Sprites may work faster than main graphics screen because sprite is a small graphics screen, and main graphics screen is much bigger in size.
sB is tuned internally to work fast. Before running it performs code checking and finds all labels and DEFs, so when running it already knows where they are located - that is why it does not matter where they are placed in program.