Skip to content

Commit c556632

Browse files
committedMay 25, 2017
refactored comment.cpp
1 parent 6ba775b commit c556632

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
 

‎src/comment.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "annotation.h"
44
#include <string>
55
#include <vector>
6+
#include <boost/range/adaptor/reversed.hpp>
67

78
struct GroupInfo {
89
std::string commentString;
@@ -303,14 +304,13 @@ void CommentParser::collectParameters(const char *fulltext, FileModule *root_mod
303304
}
304305

305306
// Look for the group to which the given assignment belong
306-
int i=0;
307-
for (; (unsigned)i < groupList.size() && groupList[i].lineNo<firstLine;i++);
308-
i--;
309-
310-
if (i >= 0) {
311-
//creating node for description
312-
shared_ptr<Expression> expr(new Literal(ValuePtr(groupList[i].commentString)));
313-
annotationList->push_back(Annotation("Group", expr));
307+
for (const auto &groupInfo :boost::adaptors::reverse(groupList)){
308+
if (groupInfo.lineNo < firstLine) {
309+
//creating node for description
310+
shared_ptr<Expression> expr(new Literal(ValuePtr(groupInfo.commentString)));
311+
annotationList->push_back(Annotation("Group", expr));
312+
break;
313+
}
314314
}
315315
assignment.addAnnotations(annotationList);
316316
}

0 commit comments

Comments
 (0)
Please sign in to comment.