[Libreoffice] [PATCH] Replace List for vector<> in sc

Petr Mladek pmladek at suse.cz
Tue Jun 7 10:32:36 PDT 2011


Hi Rafael,

I have pushed:

0003-Replace-List-for-std-vector-ExcEScenarioCell.calc.patch
0004-Make-read-only-functions-in-ExcEScenarioCell-co.calc.patch
0005-Replace-List-for-std-vector-ExcEScenario.calc.patch

=================================================

I havn't pushed 0001-Replace-List-for-std-vector-XclObj.patch because I am not sure about

--- cut ---
+     inline sal_uInt16 size () const { return static_cast<sal_uInt16>(maObjs.size()); } 
--- cut ---

If I understand it correctly, it is a replacement for

--- cut ---
sal_uIntPtr       Count() const { return nCount; }
--- cut ---
, see http://opengrok.libreoffice.org/xref/libs-gui/tools/inc/tools/contnr.hxx#99


The original object might have a bigger size. I guess that you have used sal_uInt16 because of 

--- cut ---
 sal_uInt16 XclExpObjList::Add( XclObj* pObj ) 
 { 
-    OSL_ENSURE( Count() < 0xFFFF, "XclExpObjList::Add: too much for Xcl" ); 
-    if ( Count() < 0xFFFF ) 
+    OSL_ENSURE( maObjs.size() < 0xFFFF, "XclExpObjList::Add: too much for Xcl" ); 
--- cut ---

So, it should not go over 2bytes. Though, IMHO, it is quite dangerous to
use sal_uInt16 because it could overflow easily and if it overflows, it is
again lower than 0xFFFF.

=> I would suggest to use the sal_uIntPtr.

What do you think?


===========================================================

Also haven't pushed
0002-Replace-List-with-std-vector-XclExpUserBView.calc.patch because I
am not sure about

--- cut ---
 XclExpUserBViewList::XclExpUserBViewList( const ScChangeTrack& rChangeTrack ) 
+    : aViews(rChangeTrack.GetUserCollection().GetCount())
[...]
-            List::Insert( new XclExpUserBView( pStrData->GetString(), aGUID ), LIST_APPEND ); 
+            aViews.push_back( new XclExpUserBView( pStrData->GetString(), aGUID ) ); 
--- cut ---

Why do you initialize the vector with NULL pointers?

IMHO, all the pointers will stay NULL because you later use .push_back().

For example, rChangeTrack has the collection: A B C D and GetCount() returns 4.
If you initialize the vector, you will end with the vector: 0 0 0 0 A B C D

Or did I miss something?


Best Regards,
Petr



More information about the LibreOffice mailing list