diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
index e02139d..ed4605d 100644
--- a/wp-includes/plugin.php
+++ b/wp-includes/plugin.php
@@ -206,14 +206,46 @@ function apply_filters( $tag, $value ) {
 	if ( empty($args) )
 		$args = func_get_args();
 
+	$current = current($wp_filter[$tag]);
 	do {
-		foreach( (array) current($wp_filter[$tag]) as $the_ )
-			if ( !is_null($the_['function']) ){
+		foreach( (array) $current as $the_ )
+			if ( $the_['function'] !== null ){
 				$args[1] = $value;
-				$value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
+
+				$func = $the_['function'];
+
+				if (!is_callable($func)) {
+					trigger_error("function '$func' not found or invalid function name", E_USER_WARNING);
+					continue;
+				}
+				
+				// If it's a string (function) callback, or it's PHP >= 5.4, we can do this much faster for <= 5 args
+				if (is_string($func) || $func instanceof Closure || version_compare(PHP_VERSION, '5.4.0', 'ge') === true) {
+					switch ((int) $the_['accepted_args']) {
+						case 1:
+							$value = $func($args[1]);
+							break;
+						case 2:
+							$value = $func($args[1], $args[2]);
+							break;
+						case 3:
+							$value = $func($args[1], $args[2], $args[3]);
+							break;
+						case 4:
+							$value = $func($args[1], $args[2], $args[3], $args[4]);
+							break;
+						case 5:
+							$value = $func($args[1], $args[2], $args[3], $args[4], $args[5]);
+							break;
+						default:
+							$value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
+					}
+				} else {
+					$value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
+				}
 			}
 
-	} while ( next($wp_filter[$tag]) !== false );
+	} while ( ($current = next($wp_filter[$tag])) !== false );
 
 	array_pop( $wp_current_filter );
 
