mrjackniko Posted May 10, 2023 Share Posted May 10, 2023 (edited) Hi, so i have a table which represents a custom object. It has several member variables and member functions. So, i want to tie a function to an event. Now, i could either tie an event handler to each custom object instance so i would have the same amount of handlers and instances and the source of that event handler would be that instance or i could create a table "instances" where i can use these custom objects as keys and the value would be either "true" if it exists or "nil" if it doesn't so i would have constant time access and would use a event handler which calls a function that accesses that table and checks if that object exists or not. Which method is more efficient? I am thinking that the first method might be slightly faster since the event is triggered only for a specific object but at the cost of memory since there is an event handler for each object. The second might be a bit slower since the event is triggered for each object but then again it does not loop through the table, it accesses it instantly. Or am i wrong? Edited May 10, 2023 by mrjackniko Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now