Archived

This topic is now archived and is closed to further replies.

This topic is 5502 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello! i want to create a realy simple script system. It need to be fast, but i dont want to compile to machine code. first i could parshe my script into bytecode, and then have alot of switch states, that selected the right action... BUT! wouldnt it be faster if i created a class for each function, and then linked listed them:

class Base{
virtual void do_something(void)=0;
Base *next;//set to 0 by constructor

};
class DoLookAtThing : public Base{
short data_for_this_function;//set by constructor

void do_something(void){
//Look at thing

if (next!=0){next->do_something();};
};
};

I think i need 100 - 200 commands, and all the data will be stored in the command class... (no need for variables) would this be fast? is there a better way to compile from script to functions?

Share on other sites
Use switch. As long as the switch values are sequential, it''ll be compiled into a fast lookup-table. Look up some CPU emulator sources for inspiration.

2DNow - Specializing in yesterday''s technology today!

• Forum Statistics

• Total Topics
628675
• Total Posts
2984169

• 13
• 12
• 9
• 10
• 9