Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28365/src/gui
Modified Files:
wxllist.cpp
Log Message:
optimization: prune consecutive layout command objects as latter overrides the
former anyhow
Index: wxllist.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxllist.cpp,v
retrieving revision 1.165
retrieving revision 1.166
diff -b -u -2 -r1.165 -r1.166
--- wxllist.cpp 14 Sep 2004 15:53:02 -0000 1.165
+++ wxllist.cpp 9 Jul 2005 20:38:18 -0000 1.166
@@ -921,5 +921,5 @@
bool
-wxLayoutLine::Insert(CoordType xpos, wxLayoutObject *obj)
+wxLayoutLine::Insert(CoordType xpos, wxLayoutObject *obj, CoordType *pLenOrig)
{
wxASSERT(xpos >= 0);
@@ -928,4 +928,11 @@
MarkDirty(xpos);
+ // ensure that len pointer is always valid
+ CoordType lenLocal;
+ CoordType *pLen = pLenOrig ? pLenOrig : &lenLocal;
+
+ // normal case
+ *pLen = obj->GetLength();
+
CoordType offset;
wxLOiterator i = FindObject(xpos, &offset);
@@ -935,5 +942,5 @@
{
m_ObjectList.push_back(obj);
- m_Length += obj->GetLength();
+ m_Length += *pLen;
return true;
}
@@ -946,5 +953,5 @@
{ // insert before this object
m_ObjectList.insert(i,obj);
- m_Length += obj->GetLength();
+ m_Length += *pLen;
return true;
}
@@ -952,5 +959,21 @@
{
if( i == m_ObjectList.tail()) // last object?
+ {
+ // optimization: it's useless to have 2 command objects in a row as
+ // the latter overrides the former anyhow, so drop the previous one
+ if ( obj->GetType() == WXLO_TYPE_CMD )
+ {
+ if ( m_ObjectList.back()->GetType() == WXLO_TYPE_CMD )
+ {
+ delete m_ObjectList.pop_back();
+
+ // effective length is 0 as we added 1 and removed 1 object of
+ // the same type
+ *pLen = 0;
+ }
+ }
+
m_ObjectList.push_back(obj);
+ }
else
{ // insert after current object
@@ -958,5 +981,5 @@
m_ObjectList.insert(i,obj);
}
- m_Length += obj->GetLength();
+ m_Length += *pLen;
return true;
}
@@ -972,5 +995,5 @@
// before it we insert the new object
m_ObjectList.insert(i,obj);
- m_Length += obj->GetLength();
+ m_Length += *pLen;
// and before that we insert the left half
m_ObjectList.insert(i,new wxLayoutObjectText(left));
@@ -2247,7 +2270,11 @@
AddCursorPosToUpdateRect();
- m_CursorLine->Insert(m_CursorPos.x, obj);
- m_CursorPos.x += obj->GetLength();
+ CoordType len;
+ m_CursorLine->Insert(m_CursorPos.x, obj, &len);
+ if ( len != 0 )
+ {
+ m_CursorPos.x += len;
m_movedCursor = true;
+ }
if(m_AutoFormat)
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates