Use parallel syntax highlighting API in differential
Summary: Use the new API from D322 to highlight text in parallel in Differential. Test Plan: Verified that pygemntize calls started within 20ms of one another in DarkConsole (also: added a feature to let me do this) instead of running serially. Reviewed By: aran Reviewers: jungejason, tuomaspelkonen, aran CC: aran Differential Revision: 323
This commit is contained in:
@@ -435,8 +435,26 @@ class DifferentialChangesetParser {
|
||||
$this->oldRender = explode("\n", phutil_escape_html($old_corpus_block));
|
||||
$this->newRender = explode("\n", phutil_escape_html($new_corpus_block));
|
||||
} else {
|
||||
$this->oldRender = $this->sourceHighlight($this->old, $old_corpus_block);
|
||||
$this->newRender = $this->sourceHighlight($this->new, $new_corpus_block);
|
||||
$old_future = $this->getHighlightFuture($old_corpus_block);
|
||||
$new_future = $this->getHighlightFuture($new_corpus_block);
|
||||
$futures = array(
|
||||
'old' => $old_future,
|
||||
'new' => $new_future,
|
||||
);
|
||||
foreach (Futures($futures) as $key => $future) {
|
||||
switch ($key) {
|
||||
case 'old':
|
||||
$this->oldRender = $this->processHighlightedSource(
|
||||
$this->old,
|
||||
$future->resolve());
|
||||
break;
|
||||
case 'new':
|
||||
$this->newRender = $this->processHighlightedSource(
|
||||
$this->new,
|
||||
$future->resolve());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->applyIntraline(
|
||||
@@ -648,10 +666,13 @@ class DifferentialChangesetParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected function sourceHighlight($data, $corpus) {
|
||||
$result = $this->highlightEngine->highlightSource(
|
||||
protected function getHighlightFuture($corpus) {
|
||||
return $this->highlightEngine->getHighlightFuture(
|
||||
$this->filetype,
|
||||
$corpus);
|
||||
}
|
||||
|
||||
protected function processHighlightedSource($data, $result) {
|
||||
|
||||
$result_lines = explode("\n", $result);
|
||||
foreach ($data as $key => $info) {
|
||||
|
||||
@@ -20,6 +20,7 @@ phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
||||
phutil_require_module('phutil', 'filesystem');
|
||||
phutil_require_module('phutil', 'filesystem/tempfile');
|
||||
phutil_require_module('phutil', 'future');
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'markup/syntax/engine/default');
|
||||
|
||||
Reference in New Issue
Block a user