1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +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:
vrana 2012-08-14 15:03:02 -07:00
parent 012370c6ab
commit ea0fe6d64b

View file

@ -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!");