Commit 1fcf0ca8 authored by Russell Smith's avatar Russell Smith
Browse files

MDL-35628 performance: Remove dirname() where possible.

dirname() is a slow function compared with __DIR__ and using
'/../'.  Moodle has a large number of legacy files that are included
each time a page loads and is not able to use an autoloader as it is
functional code.  This allows those required includes to perform as
best as possible in this situation.
parent 4ee8ef5d
......@@ -26,7 +26,7 @@
define('AJAX_SCRIPT', true);
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->dirroot . '/badges/lib/backpacklib.php');
require_once($CFG->libdir . '/filelib.php');
require_once($CFG->libdir . '/badgeslib.php');
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
require_once($CFG->libdir . '/filelib.php');
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
$badgeid = required_param('id', PARAM_INT);
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
$badgeid = optional_param('badgeid', 0, PARAM_INT); // Badge ID.
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
require_once($CFG->dirroot . '/badges/criteria_form.php');
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
require_once($CFG->dirroot . '/badges/edit_form.php');
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
$json = optional_param('badge', null, PARAM_RAW);
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
$type = required_param('type', PARAM_INT);
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
require_once($CFG->dirroot . '/badges/backpack_form.php');
require_once($CFG->dirroot . '/badges/lib/backpacklib.php');
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
require_once($CFG->libdir . '/filelib.php');
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
require_once($CFG->dirroot . '/badges/edit_form.php');
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
$badgeid = required_param('id', PARAM_INT);
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once('preferences_form.php');
$url = new moodle_url('/badges/preferences.php');
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
$badgeid = required_param('id', PARAM_INT);
......
......@@ -24,7 +24,7 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
$type = required_param('type', PARAM_INT);
......
......@@ -23,7 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__).'/../../config.php');
require_once(__DIR__.'/../../config.php');
require_once("{$CFG->libdir}/completionlib.php");
// Load data.
......
......@@ -21,8 +21,8 @@
* @copyright 2012 Adam Olley <adam.olley@netspot.com.au>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once(dirname(__FILE__) . '/locallib.php');
require_once(__DIR__ . '/../../config.php');
require_once(__DIR__ . '/locallib.php');
require_sesskey();
require_login();
......
......@@ -23,8 +23,8 @@
*/
define('AJAX_SCRIPT', true);
require_once(dirname(__FILE__) . '/../../config.php');
require_once(dirname(__FILE__) . '/locallib.php');
require_once(__DIR__ . '/../../config.php');
require_once(__DIR__ . '/locallib.php');
require_sesskey();
require_login();
......
......@@ -23,7 +23,7 @@
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once(__DIR__ . '/../../config.php');
require_once($CFG->libdir . '/formslib.php');
require_once($CFG->libdir .'/simplepie/moodle_simplepie.php');
......
......@@ -22,7 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once(__DIR__ . '/../../config.php');
require_once($CFG->libdir . '/tablelib.php');
require_login();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment