Jump to content

EventHandler performance question


Recommended Posts

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 by mrjackniko
Link to comment
  • mrjackniko changed the title to EventHandler performance question

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...