Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
splice is quicker
  • Loading branch information
sheldon committed Jan 24, 2012
1 parent d0a30ab commit fb23607
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions core/WaxEvent.php
Expand Up @@ -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;
}

Expand Down

0 comments on commit fb23607

Please sign in to comment.