From ba26f6768723e3998afaf9936c039827b9f044a5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 2 Feb 2011 16:36:53 -0800 Subject: [PATCH] Add some comment caching stuff. --- .../storage/comment/DifferentialComment.php | 1 + .../DifferentialInlineComment.php | 1 + .../DifferentialRevisionCommentView.php | 12 +++- .../PhabricatorXHProfProfileSymbolView.php | 56 ++++++++++--------- src/storage/lisk/dao/LiskDAO.php | 9 ++- 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/applications/differential/storage/comment/DifferentialComment.php b/src/applications/differential/storage/comment/DifferentialComment.php index fa4eb2fc40..1349ddc772 100755 --- a/src/applications/differential/storage/comment/DifferentialComment.php +++ b/src/applications/differential/storage/comment/DifferentialComment.php @@ -22,5 +22,6 @@ class DifferentialComment extends DifferentialDAO { protected $revisionID; protected $action; protected $content; + protected $cache; } diff --git a/src/applications/differential/storage/inlinecomment/DifferentialInlineComment.php b/src/applications/differential/storage/inlinecomment/DifferentialInlineComment.php index 8b2446c759..502757e87c 100644 --- a/src/applications/differential/storage/inlinecomment/DifferentialInlineComment.php +++ b/src/applications/differential/storage/inlinecomment/DifferentialInlineComment.php @@ -29,5 +29,6 @@ class DifferentialInlineComment extends DifferentialDAO { protected $lineLength; protected $content; + protected $cache; } diff --git a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php index 2ef005669a..9c174583fd 100644 --- a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php +++ b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php @@ -69,9 +69,19 @@ final class DifferentialRevisionCommentView extends AphrontView { $content = $comment->getContent(); if (strlen(rtrim($content))) { $title = "{$author_link} {$verb} this revision:"; + $cache = $comment->getCache(); + if (strlen($cache)) { + $content = $cache; + } else { + $content = $this->markupEngine->markupText($content); + if ($comment->getID()) { + $comment->setCache($content); + $comment->save(); + } + } $content = '
'. - $this->markupEngine->markupText($content). + $content. '
'; } else { $title = null; diff --git a/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php b/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php index 522641f087..bfdaf3b502 100644 --- a/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php +++ b/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php @@ -72,8 +72,6 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView { '', '', '', - '', - '', ); $rows[] = array( phutil_render_tag( @@ -84,9 +82,7 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView { phutil_escape_html($symbol)), $flat[$symbol]['ct'], $flat[$symbol]['wt'], - '', - $flat[$symbol]['excl_wt'], - '', + '100%', ); $rows[] = array( @@ -94,8 +90,6 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView { '', '', '', - '', - '', ); foreach ($parents as $key => $name) { $rows[] = array( @@ -108,8 +102,6 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView { $data[$key]['ct'], $data[$key]['wt'], '', - $data[$key]['wt'], - '', ); } @@ -119,33 +111,26 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView { '', '', '', - '', - '', ); + $child_rows = array(); foreach ($children as $key => $name) { - $rows[] = array( - phutil_render_tag( - 'a', - array( - 'href' => $base_uri.'?symbol='.$name, - ), - phutil_escape_html($name)), + $child_rows[] = array( + $name, $data[$key]['ct'], $data[$key]['wt'], - '', - $data[$key]['wt'], - '', + $data[$key]['wt'] / $flat[$symbol]['wt'], ); } + $child_rows = isort($child_rows, 2); + $child_rows = array_reverse($child_rows); + $rows = array_merge($rows, $this->formatRows($child_rows)); $table = new AphrontTableView($rows); $table->setHeaders( array( 'Symbol', 'Count', - 'Incl Wall Time', - '%', - 'Excl Wall Time', + 'Wall Time', '%', )); $table->setColumnClasses( @@ -154,8 +139,6 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView { 'n', 'n', 'n', - 'n', - 'n', )); $panel = new AphrontPanelView(); @@ -164,4 +147,25 @@ class PhabricatorXHProfProfileSymbolView extends AphrontView { return $panel->render(); } + + private function formatRows($rows) { + $base_uri = $this->baseURI; + + $result = array(); + foreach ($rows as $row) { + $result[] = array( + phutil_render_tag( + 'a', + array( + 'href' => $base_uri.'?symbol='.$row[0], + ), + phutil_escape_html($row[0])), + number_format($row[1]), + number_format($row[2]).' us', + sprintf('%.1f%%', 100 * $row[3]), + ); + } + return $result; + } + } diff --git a/src/storage/lisk/dao/LiskDAO.php b/src/storage/lisk/dao/LiskDAO.php index 667270a4d9..7a821a6cc0 100644 --- a/src/storage/lisk/dao/LiskDAO.php +++ b/src/storage/lisk/dao/LiskDAO.php @@ -573,11 +573,16 @@ abstract class LiskDAO { */ protected function checkProperty($property) { static $properties = null; - if (!isset($properties)) { + if ($properties === null) { $properties = $this->getProperties(); } + + $property = strtolower($property); + if (empty($properties[$property])) { + return null; + } - return idx($properties, strtolower($property)); + return $properties[$property]; }