@@ -43,61 +43,62 @@ static std::string getSimpleNodeLabel(const BasicBlock *Node) {
4343
4444 Node->printAsOperand (OS, false );
4545 return OS.str ();
46- }
46+ }
4747
48- std::list<std::vector<inst>::iterator>::iterator findstring (
48+ std::list<std::vector<inst>::iterator>::iterator findString (
4949 std::list<std::vector<inst>::iterator>::iterator first,
5050 std::list<std::vector<inst>::iterator>::iterator last,
5151 std::string s){
52- while (first!=last) {
53- if ((**first).gethead ()==s) return first;
54- ++first;
55- }
56- return last;
52+ while (first!=last) {
53+ if ((**first).gethead ()==s) return first;
54+ ++first;
5755 }
56+ return last;
57+ }
5858
5959std::list<std::vector<inst>::iterator> intersection (
6060 std::list<std::vector<inst>::iterator> a,
6161 std::list<std::vector<inst>::iterator> b ) {
62- std::string s1,s2;
63- int n1,n2;
64- char c (' %' );
65- std::list<std::vector<inst>::iterator> o;
66- std::list<std::vector<inst>::iterator>::iterator first1 = a.begin (),
67- first2 = b.begin (),
68- last1=a.end (), last2=b.end ();
69- while (first1 != last1 && first2 != last2) {
70- s1 = (**first1).gethead ();
71- s2 = (**first2).gethead ();
72- if (s1.at (0 )!=c) {
73- if (findstring (first2,last2,s1)!=last2) o.push_back (*first1);
74- first1++;
75- continue ;
76- }
77-
78- else if (s2.at (0 )!=c) {
79- if (findstring (first1,last1,s2)!=last1) o.push_back (*first2);
80- first2++;
81- continue ;
82- }
83-
84- if (s1 < s2) ++first1;
85- else {
86- if (!(s2 < s1)) o.push_back (*first1++);
87- ++first2;
88- }
62+ std::string s1,s2;
63+ int n1,n2;
64+ char c (' %' );
65+ std::list<std::vector<inst>::iterator> o;
66+ std::list<std::vector<inst>::iterator>::iterator first1 = a.begin (),
67+ first2 = b.begin (),
68+ last1=a.end (),
69+ last2=b.end ();
70+ while (first1 != last1 && first2 != last2) {
71+ s1 = (**first1).gethead ();
72+ s2 = (**first2).gethead ();
73+ if (s1.at (0 )!=c) {
74+ if (findString (first2,last2,s1)!=last2) o.push_back (*first1);
75+ first1++;
76+ continue ;
77+ }
78+
79+ else if (s2.at (0 )!=c) {
80+ if (findString (first1,last1,s2)!=last1) o.push_back (*first2);
81+ first2++;
82+ continue ;
8983 }
90- return o;
84+
85+ if (s1 < s2) ++first1;
86+ else {
87+ if (!(s2 < s1)) o.push_back (*first1++);
88+ ++first2;
89+ }
9190 }
91+ return o;
92+ }
9293
9394std::vector<collist*> CreateTable (std::string inputfile) {
9495 int n,m,colnum;
9596 char c (' !' );
9697 std::string line, word;
9798 std::ifstream input (inputfile);
98- // ofstream output(argv[2]);
99- std::vector<collist*> table;
10099
100+ std::vector<collist*> table;
101+ table.reserve (1024 );
101102 while (getline (input, line)) {
102103 std::stringstream iss (line);
103104 iss >> word;
@@ -109,15 +110,13 @@ std::vector<collist*> CreateTable(std::string inputfile) {
109110 n = atoi (word.substr (0 ,word.size ()-1 ).c_str ()); // linenum
110111 iss >> word >> word; // colnum,
111112 colnum = atoi (word.substr (0 ,word.size ()-1 ).c_str ()); // colnum
112-
113+
113114 if (table.size () <= n) {
114115 table.resize (n+1 );
115116 table.at (n) = new collist ();
116117 }
117118 else if (table.at (n) == NULL ) table.at (n) = new collist ();
118119 table.at (n) -> push (new col (colnum));
119-
120-
121120 }
122121 return table;
123122}
0 commit comments