Speed.. functions or plain code?
Moderator: General Moderators
Speed.. functions or plain code?
I am making an engine that will be looping many times, a switch statement. Should i get the algorithm located in the statements into functions? Will that increase the execution speed? Or should i leave is as a plain code?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
First of all, do you know that it is too slow. If you don't -- why optimize.
All inline will technically be the fastest. But you need to maintain the code, so if there is reusable code and you duplicate it several times you will have to maintain all the copies in parallel.
And finally, why are you looping around a switch statement in the first place? Is sounds like there might be a better design...
All inline will technically be the fastest. But you need to maintain the code, so if there is reusable code and you duplicate it several times you will have to maintain all the copies in parallel.
And finally, why are you looping around a switch statement in the first place? Is sounds like there might be a better design...
(#10850)
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact: