Commits

O01eg committed 8f27ead

GP: Optimize IF with TRUE branch equal to FALSE branch.

Comments (0)

Files changed (2)

   - Move functions to base GP folder.
   - Remove ADF from generated objects.
   - Optimize %0 as returning LIST.
+  - Optimize IF with TRUE branch equal to FALSE branch.
 
 Version 0.0.5 2012-09-05
  - Support for C++0x (GCC 4.5.3)
 				bool check_1st = true;
 				VM::Object t = obj.GetTail();
 				std::stack<VM::Object> stack;
+
+				/// \todo Rewrite to foreach.
 				while((! t.IsNIL()) && (t.GetType() == VM::LIST))
 				{
 					VM::Object opt(env);
 					stack.push(std::move(opt));
 
 					t = t.GetTail();
-				}
+				} //while((! t.IsNIL()) && (t.GetType() == VM::LIST))
 
 				t = VM::Object(env);
 				while(! stack.empty())
 				{
 					return GP::Optimize(VM::Object(head, t), prog, rules, mode);
 				}
+
+				if(! check_no_if) // get IF, t.GetTail() = ( TRUE-BRANCH FALSE-BRANCH )
+				{
+					if(t.GetTail().GetHead() == t.GetTail().GetTail().GetHead()) // if TRUE-BRACH equal to FALSE-BRANCH
+					{
+						return t.GetTail().GetHead();
+					}
+				}
+
 				return VM::Object(head, t);
 			}
 		}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.