1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 09:20:58 +01:00

Improve remarkup performance (Phabricator)

Summary: As we've moved more remarkup logic post-cache (e.g., to implement policy-aware rules), we're paying more of a price for it. Improve performance in Phabricator by sharing engine instances where possible.

Test Plan: With next diff, this drops 75% of the cost of markup handling in Conpherence.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D5510
This commit is contained in:
epriestley 2013-04-01 12:06:02 -07:00
parent cd07182e9c
commit 7b07f6ab3d
2 changed files with 22 additions and 1 deletions

View file

@ -61,7 +61,7 @@ abstract class PhabricatorApplicationTransactionComment
public function newMarkupEngine($field) {
return PhabricatorMarkupEngine::newMarkupEngine(array());
return PhabricatorMarkupEngine::getEngine();
}

View file

@ -337,6 +337,27 @@ final class PhabricatorMarkupEngine {
return self::newMarkupEngine($options);
}
/**
* @task engine
*/
public static function getEngine($ruleset = 'default') {
static $engines = array();
if (isset($engines[$ruleset])) {
return $engines[$ruleset];
}
$engine = null;
switch ($ruleset) {
case 'default':
$engine = self::newMarkupEngine(array());
break;
default:
throw new Exception("Unknown engine ruleset: {$ruleset}!");
}
$engines[$ruleset] = $engine;
return $engine;
}
/**
* @task engine