!
Hubzilla DevelopmentAs far as I can tell, there haven't been a lot of developers using the many many hooks with in Hubzilla to alter it's behavior. Coming from developing in WordPress, I love all the hooks!
I was looking at the include/plugin.php call_hooks() function, however, and remembered something I ran across a long time ago - array_key_exists is slow.
Is there any reason not to change
if((is_array(App::$hooks)) && (array_key_exists($name, App::$hooks))) { ... }
to
if (isset(App::$hooks[$name])) { ... }
???
The key thing to know about isset is that it checks both whether the variable (or array element) exists AND that it is NOT null. Since call_hooks launches right into a foreach loop using App::$hooks[$name], I don't see any problem with the substitution.
Yes, it's a micro-optimzation, and with only about 450 call_hooks in the codebase (by a very quick grep|wc), it may not be a huge boost, I know for a fact, some of those calls are in loops and may run a number of times each - in which case every little bit helps! It also would reduce the twinge I feel every time I look at the code and say, "You know, it'd be really nice if I could tweak this or that with an addon just before this next section of code runs".