/** * @param string $sel the selector * @param boolean $enableRequestPart true if the selector can contain the request part * @param boolean $toRetrieveUrl true if the goal to have this selector is to generate an url */ function __construct($sel, $enableRequestPart = false, $toRetrieveUrl = false) { $coord = jApp::coord(); $this->forUrl = $toRetrieveUrl; // jSelectorAct is called by the significant url engine parser, before // jcoordinator set its properties, so we set a value to avoid a // parameter error on jelix_scan_action_sel. the value doesn't matter // since the significant parser call jSelectorAct only for 404 page if ($coord->actionName === null) { $coord->actionName = 'default:index'; } if (jelix_scan_action_sel($sel, $this, $coord->actionName)) { if ($this->module == '#') { $this->module = $coord->moduleName; } elseif ($this->module == '') { $this->module = jApp::getCurrentModule(); } if ($this->request == '' || !$enableRequestPart) { $this->request = $coord->request->type; } $this->_createPath(); } else { throw new jExceptionSelector('jelix~errors.selector.invalid.syntax', array($sel, $this->type)); } }
{ public $module; public $resource; public $request; } $t1 = microtime(true); for ($i = 0; $i < 1000; $i++) { $o = new obj(); module_selector("aaa~bbb", $o); } $t2 = microtime(true); for ($i = 0; $i < 1000; $i++) { $o = new obj(); jelix_scan_module_sel("aaa~bbb", $o); } $t3 = microtime(true); echo "module_selector = " . ($t2 - $t1) . "\n"; echo "jelix_scan_selector = " . ($t3 - $t2) . "\n"; $t1 = microtime(true); for ($i = 0; $i < 1000; $i++) { $o = new obj(); action_selector("aaa~bbb@classic", $o); } $t2 = microtime(true); for ($i = 0; $i < 1000; $i++) { $o = new obj(); jelix_scan_action_sel("aaa~bbb@classic", $o, "machin_bidule"); } $t3 = microtime(true); echo "action_selector = " . ($t2 - $t1) . "\n"; echo "jelix_scan_selector = " . ($t3 - $t2) . "\n";