Permalink
Browse files

splice is quicker

  • Loading branch information...
sheldon committed Jan 24, 2012
1 parent d0a30ab commit fb2360719db928f7fa277b5d4389092f376c8a54
Showing with 2 additions and 10 deletions.
  1. +2 −10 core/WaxEvent.php
View
@@ -91,17 +91,9 @@ public static function add_after($name, $existing, $callback) {
*/
private static function insert_event($name, $key, $callback) {
if(in_array($callback, self::$events[$name], true)) return false;
-
+
// Add the new event at the given key location
- self::$events[$name] = array_merge
- (
- // Events before the key
- array_slice(self::$events[$name], 0, $key),
- // New event callback
- array($callback),
- // Events after the key
- array_slice(self::$events[$name], $key)
- );
+ array_splice(self::$events[$name], $key, 0, $callback);
return true;
}

0 comments on commit fb23607

Please sign in to comment.