mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Optimize matching regexps in Herald rules
Summary: We spend 6.37 s in this condition on a big diff. By adding the 'S' flag, the time is down to 2.15 s. Test Plan: `DifferentialRevisionEditor::newRevisionFromConduitWithDiff()` Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3284
This commit is contained in:
parent
012370c6ab
commit
ea0fe6d64b
1 changed files with 4 additions and 1 deletions
|
@ -350,7 +350,10 @@ final class HeraldEngine {
|
|||
break;
|
||||
case HeraldConditionConfig::CONDITION_REGEXP:
|
||||
foreach ((array)$object_value as $value) {
|
||||
$result = @preg_match($test_value, $value);
|
||||
// We add the 'S' flag because we use the regexp multiple times.
|
||||
// It shouldn't cause any troubles if the flag is already there
|
||||
// - /.*/S is evaluated same as /.*/SS.
|
||||
$result = @preg_match($test_value . 'S', $value);
|
||||
if ($result === false) {
|
||||
$transcript->setNote(
|
||||
"Regular expression is not valid!");
|
||||
|
|
Loading…
Reference in a new issue