From d93f7683c9744ff7ac23514922ba541d16a9df6e Mon Sep 17 00:00:00 2001 From: Pawel Date: Fri, 24 Aug 2012 14:18:55 +0400 Subject: [PATCH] 0023373: MSVC++ warnings issued during compilation for 64bits, 'Sparse Arrays' Replaced 'Standard_Integer' with 'Standard_Size' to avoid compiler warning. Removed redundant casting to 'Standard_Size'. Removed code checking if a 'Standard_Size' variable is negative. --- src/NCollection/NCollection_SparseArray.hxx | 22 ++++++++-------- .../NCollection_SparseArrayBase.cxx | 26 ++++++++----------- .../NCollection_SparseArrayBase.hxx | 10 +++---- src/TObj/TObj_TIntSparseArray.cxx | 10 +++---- src/TObj/TObj_TIntSparseArray.hxx | 12 ++++----- 5 files changed, 38 insertions(+), 42 deletions(-) diff --git a/src/NCollection/NCollection_SparseArray.hxx b/src/NCollection/NCollection_SparseArray.hxx index 0d93a03d81..bb1b4b3da6 100755 --- a/src/NCollection/NCollection_SparseArray.hxx +++ b/src/NCollection/NCollection_SparseArray.hxx @@ -85,31 +85,31 @@ public: //!@{ //! Direct const access to the item - const TheItemType& Value (const Standard_Integer theIndex) const + const TheItemType& Value (const Standard_Size theIndex) const { return *(const TheItemType*)this->getValue(theIndex); } //! Const access to the item - operator() - const TheItemType& operator () (const Standard_Integer theIndex) const + const TheItemType& operator () (const Standard_Size theIndex) const { return Value (theIndex); } //! Modification access to the item - TheItemType& ChangeValue (const Standard_Integer theIndex) + TheItemType& ChangeValue (const Standard_Size theIndex) { return *(TheItemType*)(this->getValue (theIndex)); } //! Access to the item - operator() - TheItemType& operator () (const Standard_Integer theIndex) + TheItemType& operator () (const Standard_Size theIndex) { return ChangeValue (theIndex); } //! Set a value at specified index method - TheItemType& SetValue (const Standard_Integer theIndex, + TheItemType& SetValue (const Standard_Size theIndex, const TheItemType& theValue) { return *(TheItemType*)this->setValue(theIndex, (Standard_Address)&theValue); @@ -134,33 +134,33 @@ public: } //! Direct const access to the item - const TheItemType& Find (const Standard_Integer theIndex) const + const TheItemType& Find (const Standard_Size theIndex) const { return *(TheItemType*)this->getValue(theIndex); } //! Modification access to the item; allocates space if //! necessary and marks the item as defined - TheItemType& ChangeFind (const Standard_Integer theIndex) + TheItemType& ChangeFind (const Standard_Size theIndex) { return *(TheItemType*)(this->changeValue (theIndex)); } //! Set a value as explicit method - TheItemType& Bind (const Standard_Integer theIndex, + TheItemType& Bind (const Standard_Size theIndex, const TheItemType& theValue) { return SetValue(theIndex, theValue); } //! Returns True if the item is defined - Standard_Boolean IsBound (const Standard_Integer theIndex) const + Standard_Boolean IsBound (const Standard_Size theIndex) const { return this->HasValue(theIndex); } //! Remove the item from array - Standard_Boolean UnBind (const Standard_Integer theIndex) + Standard_Boolean UnBind (const Standard_Size theIndex) { return this->UnsetValue(theIndex); } @@ -203,7 +203,7 @@ public: } //! Access current index with 'a-la map' interface - Standard_Integer Key (void) const { return Index(); } + Standard_Size Key (void) const { return Index(); } }; /** diff --git a/src/NCollection/NCollection_SparseArrayBase.cxx b/src/NCollection/NCollection_SparseArrayBase.cxx index 22df70799a..89594bba98 100755 --- a/src/NCollection/NCollection_SparseArrayBase.cxx +++ b/src/NCollection/NCollection_SparseArrayBase.cxx @@ -202,12 +202,10 @@ void NCollection_SparseArrayBase::exchange (NCollection_SparseArrayBase& theOthe //purpose : //======================================================================= -Standard_Address NCollection_SparseArrayBase::setValue (const Standard_Integer theIndex, +Standard_Address NCollection_SparseArrayBase::setValue (const Standard_Size theIndex, const Standard_Address theValue) { - Standard_OutOfRange_Raise_if (theIndex<0,"NCollection_SparseArray::SetValue()") - Standard_Size anIndex = (Standard_Size)theIndex; - Standard_Size iBlock = anIndex / myBlockSize; + Standard_Size iBlock = theIndex / myBlockSize; // resize blocks array if necessary if ( iBlock >= myNbBlocks ) @@ -222,7 +220,7 @@ Standard_Address NCollection_SparseArrayBase::setValue (const Standard_Integer t Block aBlock (getBlock (anAddr)); // mark item as defined - Standard_Size anInd = anIndex % myBlockSize; + Standard_Size anInd = theIndex % myBlockSize; Standard_Address anItem = getItem (aBlock, anInd); // either create an item by copy constructor if it is new, or assign it @@ -243,14 +241,13 @@ Standard_Address NCollection_SparseArrayBase::setValue (const Standard_Integer t //purpose : //======================================================================= -Standard_Boolean NCollection_SparseArrayBase::HasValue (const Standard_Integer theIndex) const +Standard_Boolean NCollection_SparseArrayBase::HasValue (const Standard_Size theIndex) const { - Standard_Size anIndex = (Standard_Size)theIndex; - Standard_Size iBlock = anIndex / myBlockSize; - if ( theIndex < 0 || iBlock >= myNbBlocks || + Standard_Size iBlock = theIndex / myBlockSize; + if ( iBlock >= myNbBlocks || ! myData[iBlock] ) return Standard_False; - return getBlock(myData[iBlock]).IsSet(anIndex % myBlockSize) ? Standard_True : Standard_False; + return getBlock(myData[iBlock]).IsSet(theIndex % myBlockSize) ? Standard_True : Standard_False; } //======================================================================= @@ -258,16 +255,15 @@ Standard_Boolean NCollection_SparseArrayBase::HasValue (const Standard_Integer t //purpose : //======================================================================= -Standard_Boolean NCollection_SparseArrayBase::UnsetValue (const Standard_Integer theIndex) +Standard_Boolean NCollection_SparseArrayBase::UnsetValue (const Standard_Size theIndex) { // check that the item is defined - Standard_Size anIndex = (Standard_Size)theIndex; - Standard_Size iBlock = anIndex / myBlockSize; - if ( theIndex < 0 || iBlock >= myNbBlocks || ! myData[iBlock] ) + Standard_Size iBlock = theIndex / myBlockSize; + if ( iBlock >= myNbBlocks || ! myData[iBlock] ) return Standard_False; Block aBlock (getBlock(myData[iBlock])); - Standard_Size anInd = anIndex % myBlockSize; + Standard_Size anInd = theIndex % myBlockSize; if ( ! aBlock.Unset(anInd) ) return Standard_False; diff --git a/src/NCollection/NCollection_SparseArrayBase.hxx b/src/NCollection/NCollection_SparseArrayBase.hxx index 45fe38bfca..d8d7320fb4 100755 --- a/src/NCollection/NCollection_SparseArrayBase.hxx +++ b/src/NCollection/NCollection_SparseArrayBase.hxx @@ -45,11 +45,11 @@ public: Standard_Size Size () const { return mySize; } //! Check whether the value at given index is set - Standard_EXPORT Standard_Boolean HasValue (const Standard_Integer theIndex) const; + Standard_EXPORT Standard_Boolean HasValue (const Standard_Size theIndex) const; //! Deletes the item from the array; //! returns True if that item was defined - Standard_EXPORT Standard_Boolean UnsetValue (const Standard_Integer theIndex); + Standard_EXPORT Standard_Boolean UnsetValue (const Standard_Size theIndex); //!@} @@ -231,7 +231,7 @@ protected: } //! Direct const access to the item - Standard_Address getValue (const Standard_Integer theIndex) const + Standard_Address getValue (const Standard_Size theIndex) const { Standard_OutOfRange_Raise_if (!HasValue(theIndex),"NCollection_SparseArray::Value()") return Block::ToArray(myData[theIndex/myBlockSize], myBlockSize, myItemSize) + @@ -239,12 +239,12 @@ protected: } //! Set a value to the specified item; returns address of the set item - Standard_EXPORT Standard_Address setValue (const Standard_Integer theIndex, + Standard_EXPORT Standard_Address setValue (const Standard_Size theIndex, const Standard_Address theValue); //! Modification access to the item; allocates necessary space //! and marks the item as defined - Standard_EXPORT Standard_Address changeValue (const Standard_Integer theIndex); + Standard_EXPORT Standard_Address changeValue (const Standard_Size theIndex); //! Copy contents of theOther to this; //! assumes that this and theOther have exactly the same type of arguments diff --git a/src/TObj/TObj_TIntSparseArray.cxx b/src/TObj/TObj_TIntSparseArray.cxx index 482229f928..99867b03cf 100755 --- a/src/TObj/TObj_TIntSparseArray.cxx +++ b/src/TObj/TObj_TIntSparseArray.cxx @@ -82,7 +82,7 @@ Handle(TObj_TIntSparseArray) TObj_TIntSparseArray::Set //purpose : //======================================================================= -void TObj_TIntSparseArray::SetValue (const Standard_Integer theId, +void TObj_TIntSparseArray::SetValue (const Standard_Size theId, const Standard_Integer theValue) { // check that modification is allowed @@ -128,7 +128,7 @@ void TObj_TIntSparseArray::SetValue (const Standard_Integer theId, //purpose : //======================================================================= -void TObj_TIntSparseArray::UnsetValue (const Standard_Integer theId) +void TObj_TIntSparseArray::UnsetValue (const Standard_Size theId) { // check that modification is allowed if ( !Label().Data()->IsModificationAllowed() ) @@ -182,7 +182,7 @@ void TObj_TIntSparseArray::Clear () TObj_TIntSparseArray_VecOfData::Iterator anIt (myVector); for (; anIt.More(); anIt.Next()) { - Standard_Integer anId = anIt.Key(); + Standard_Size anId = anIt.Key(); Standard_Integer aVal = anIt.Value(); backupValue(anId, aVal, AbsentValue); } @@ -196,7 +196,7 @@ void TObj_TIntSparseArray::Clear () //purpose : //======================================================================= -void TObj_TIntSparseArray::backupValue (const Standard_Integer theId, +void TObj_TIntSparseArray::backupValue (const Standard_Size theId, const Standard_Integer theCurrValue, const Standard_Integer theNewValue) { @@ -257,7 +257,7 @@ void TObj_TIntSparseArray::Restore(const Handle(TDF_Attribute)& theDelta) TObj_TIntSparseArray_MapOfData::Iterator anIt (aDelta->myOldMap); for (; anIt.More(); anIt.Next()) { - Standard_Integer anId = anIt.Key(); + Standard_Size anId = anIt.Key(); Standard_Integer anOld = anIt.Value(); if (anOld == AbsentValue) UnsetValue (anId); diff --git a/src/TObj/TObj_TIntSparseArray.hxx b/src/TObj/TObj_TIntSparseArray.hxx index 0b62c41404..ee7929a031 100755 --- a/src/TObj/TObj_TIntSparseArray.hxx +++ b/src/TObj/TObj_TIntSparseArray.hxx @@ -62,7 +62,7 @@ class TObj_TIntSparseArray : public TDF_Attribute //! Methods for access to data //! Returns the number of stored values in the set - Standard_EXPORT Standard_Integer Size() const + Standard_EXPORT Standard_Size Size() const { return myVector.Size(); } typedef TObj_TIntSparseArray_VecOfData::ConstIterator Iterator; @@ -71,22 +71,22 @@ class TObj_TIntSparseArray : public TDF_Attribute Iterator GetIterator() const { return Iterator(myVector); } //! Returns true if the value with the given ID is present. - Standard_Boolean HasValue (const Standard_Integer theId) const + Standard_Boolean HasValue (const Standard_Size theId) const { return myVector.HasValue(theId); } //! Returns the value by its ID. //! Raises an exception if no value is stored with this ID - Standard_Integer Value (const Standard_Integer theId) const + Standard_Integer Value (const Standard_Size theId) const { return myVector.Value(theId); } //! Sets the value with the given ID. //! Raises an exception if theId is not positive - Standard_EXPORT void SetValue (const Standard_Integer theId, + Standard_EXPORT void SetValue (const Standard_Size theId, const Standard_Integer theValue); //! Unsets the value with the given ID. //! Raises an exception if theId is not positive - Standard_EXPORT void UnsetValue(const Standard_Integer theId); + Standard_EXPORT void UnsetValue(const Standard_Size theId); //! Clears the set Standard_EXPORT void Clear (); @@ -142,7 +142,7 @@ class TObj_TIntSparseArray : public TDF_Attribute }; //! backup one value - void backupValue (const Standard_Integer theId, + void backupValue (const Standard_Size theId, const Standard_Integer theCurrValue, const Standard_Integer theNewValue);