Merge "resourceloader: Optimise getMimeType() for common case"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 28 Mar 2017 07:59:45 +0000 (07:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 28 Mar 2017 07:59:45 +0000 (07:59 +0000)
includes/libs/CSSMin.php

index b1cece8..bba07e2 100644 (file)
@@ -176,6 +176,12 @@ class CSSMin {
         * @return bool|string
         */
        public static function getMimeType( $file ) {
+               // Infer the MIME-type from the file extension
+               $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) );
+               if ( isset( self::$mimeTypes[$ext] ) ) {
+                       return self::$mimeTypes[$ext];
+               }
+
                $realpath = realpath( $file );
                if (
                        $realpath
@@ -186,12 +192,6 @@ class CSSMin {
                        return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $realpath );
                }
 
-               // Infer the MIME-type from the file extension
-               $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) );
-               if ( isset( self::$mimeTypes[$ext] ) ) {
-                       return self::$mimeTypes[$ext];
-               }
-
                return false;
        }