[commit] r2049 - trunk/GME/Gme/AutoRoute

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Tue Sep 11 09:23:29 CDT 2012


Author: ksmyth
Date: Tue Sep 11 09:23:29 2012
New Revision: 2049

Log:
CList::AddEnd n times is O(n^2)

Modified:
   trunk/GME/Gme/AutoRoute/AutoRouterGraph.cpp

Modified: trunk/GME/Gme/AutoRoute/AutoRouterGraph.cpp
==============================================================================
--- trunk/GME/Gme/AutoRoute/AutoRouterGraph.cpp	Tue Sep 11 09:23:18 2012	(r2048)
+++ trunk/GME/Gme/AutoRoute/AutoRouterGraph.cpp	Tue Sep 11 09:23:29 2012	(r2049)
@@ -452,6 +452,7 @@
 	ASSERT( ret.IsEmpty() );
 
 	CPoint& thestart = start;
+	POSITION retend = NULL;
 
 	while( start != end )
 	{
@@ -462,13 +463,17 @@
 		ASSERT( dir1 == GetMajorDir(end-start) );
 		ASSERT( dir2 == Dir_None || dir2 == GetMinorDir(end-start) );
 
-		if( ret.IsEmpty() && dir2 == hintstartdir && dir2 != Dir_None )
+		if( retend == NULL && dir2 == hintstartdir && dir2 != Dir_None )
 		{
+			// i.e. std::swap(dir1, dir2);
 			dir2 = dir1;
 			dir1 = hintstartdir;
 		}
 
-		ret.AddTail(start);
+		if (retend == NULL)
+			retend = ret.AddTail(start);
+		else
+			retend = ret.InsertAfter(retend, start);
 		CPoint old = start;
 
 		CAutoRouterBox* box = GoToNextBox(start, dir1, end);
@@ -486,6 +491,7 @@
 			{
 				ASSERT( !IsPointInDirFrom(start, rect, dir2) );
 				GoToNextBox(start, dir2, end);
+				// this assert fails if two boxes are adjacent, and a connection wants to go between
 				ASSERT( IsPointInDirFrom(start, rect, dir2) );
 			}
 			else
@@ -517,7 +523,8 @@
 				GetPointCoord(start, dir2) = GetRectOuterCoord(rect, dir2);
 
 				ASSERT( start != old );
-				ret.AddTail(start);
+				ASSERT(retend != NULL);
+				retend = ret.InsertAfter(retend, start);
 
 				old = start;
 


More information about the gme-commit mailing list