[cfe-commits] r159247 - /cfe/trunk/lib/AST/CommentBriefParser.cpp

Dmitri Gribenko gribozavr at gmail.com
Tue Jun 26 18:17:34 PDT 2012


Author: gribozavr
Date: Tue Jun 26 20:17:34 2012
New Revision: 159247

URL: http://llvm.org/viewvc/llvm-project?rev=159247&view=rev
Log:
Simplify logic in BriefParser::Parse(), per Jordan's comment.

Modified:
    cfe/trunk/lib/AST/CommentBriefParser.cpp

Modified: cfe/trunk/lib/AST/CommentBriefParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentBriefParser.cpp?rev=159247&r1=159246&r2=159247&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentBriefParser.cpp (original)
+++ cfe/trunk/lib/AST/CommentBriefParser.cpp Tue Jun 26 20:17:34 2012
@@ -13,33 +13,29 @@
 namespace comments {
 
 std::string BriefParser::Parse() {
-  std::string FirstParagraph;
-  std::string Brief;
+  std::string Paragraph;
   bool InFirstParagraph = true;
   bool InBrief = false;
   bool BriefDone = false;
 
   while (Tok.isNot(tok::eof)) {
     if (Tok.is(tok::text)) {
-      if (InFirstParagraph)
-        FirstParagraph += Tok.getText();
-      if (InBrief)
-        Brief += Tok.getText();
+      if (InFirstParagraph || InBrief)
+        Paragraph += Tok.getText();
       ConsumeToken();
       continue;
     }
 
     if (!BriefDone && Tok.is(tok::command) && Tok.getCommandName() == "brief") {
+      Paragraph.clear();
       InBrief = true;
       ConsumeToken();
       continue;
     }
 
     if (Tok.is(tok::newline)) {
-      if (InFirstParagraph)
-        FirstParagraph += '\n';
-      if (InBrief)
-        Brief += '\n';
+      if (InFirstParagraph || InBrief)
+        Paragraph += '\n';
       ConsumeToken();
 
       if (Tok.is(tok::newline)) {
@@ -58,10 +54,7 @@
     ConsumeToken();
   }
 
-  if (Brief.size() > 0)
-    return Brief;
-
-  return FirstParagraph;
+  return Paragraph;
 }
 
 BriefParser::BriefParser(Lexer &L) : L(L)





More information about the cfe-commits mailing list