0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings

This commit is contained in:
rkv
2021-11-11 00:06:46 +03:00
committed by inv
parent 2b40ee81d1
commit 57c5e9e895
28 changed files with 189 additions and 246 deletions
+35 -17
View File
@@ -253,6 +253,9 @@ protected:
ListNode *Next;
};
//! Cell index type.
typedef Standard_Integer Cell_IndexType;
/**
* Auxiliary structure representing a cell in the space.
* Cells are stored in the map, each cell contains list of objects
@@ -270,14 +273,14 @@ protected:
{
for (int i = 0; i < theCellSize.Size(); i++)
{
Standard_Real val = (Standard_Real)(Inspector::Coord(i, thePnt) / theCellSize(theCellSize.Lower() + i));
Standard_Real aVal = (Standard_Real)(Inspector::Coord(i, thePnt) / theCellSize(theCellSize.Lower() + i));
//If the value of index is greater than
//INT_MAX it is decreased correspondingly for the value of INT_MAX. If the value
//of index is less than INT_MIN it is increased correspondingly for the absolute
//value of INT_MIN.
index[i] = long((val > INT_MAX - 1) ? fmod(val, (Standard_Real) INT_MAX)
: (val < INT_MIN + 1) ? fmod(val, (Standard_Real) INT_MIN)
: val);
index[i] = Cell_IndexType((aVal > INT_MAX - 1) ? fmod(aVal, (Standard_Real) INT_MAX)
: (aVal < INT_MIN + 1) ? fmod(aVal, (Standard_Real) INT_MIN)
: aVal);
}
}
@@ -324,19 +327,19 @@ protected:
{
// number of bits per each dimension in the hash code
const std::size_t aDim = index.Size();
const std::size_t aShiftBits = (BITS (long) - 1) / aDim;
unsigned int aCode = 0;
const std::size_t aShiftBits = (BITS (Cell_IndexType) - 1) / aDim;
std::size_t aCode = 0;
for (std::size_t i = 0; i < aDim; ++i)
{
aCode = (aCode << aShiftBits) ^ index[i];
aCode = (aCode << aShiftBits) ^ std::size_t(index[i]);
}
return ::HashCode(aCode, theUpperBound);
}
public:
NCollection_LocalArray<long, 10> index;
NCollection_LocalArray<Cell_IndexType, 10> index;
ListNode *Objects;
};
@@ -383,14 +386,19 @@ protected:
const Cell& theCellMin, const Cell& theCellMax,
const Target& theTarget)
{
int start = theCellMin.index[idim];
int end = theCellMax.index[idim];
for (int i=start; i <= end; i++) {
const Cell_IndexType aStart = theCellMin.index[idim];
const Cell_IndexType anEnd = theCellMax.index[idim];
for (Cell_IndexType i = aStart; i <= anEnd; ++i)
{
theCell.index[idim] = i;
if ( idim ) // recurse
{
iterateAdd (idim-1, theCell, theCellMin, theCellMax, theTarget);
}
else // add to this cell
{
add (theCell, theTarget);
}
}
}
@@ -426,14 +434,19 @@ protected:
const Cell& theCellMin, const Cell& theCellMax,
const Target& theTarget)
{
int start = theCellMin.index[idim];
int end = theCellMax.index[idim];
for (int i=start; i <= end; i++) {
const Cell_IndexType aStart = theCellMin.index[idim];
const Cell_IndexType anEnd = theCellMax.index[idim];
for (Cell_IndexType i = aStart; i <= anEnd; ++i)
{
theCell.index[idim] = i;
if ( idim ) // recurse
{
iterateRemove (idim-1, theCell, theCellMin, theCellMax, theTarget);
}
else // remove from this cell
{
remove (theCell, theTarget);
}
}
}
@@ -469,14 +482,19 @@ protected:
const Cell& theCellMin, const Cell& theCellMax,
Inspector& theInspector)
{
int start = theCellMin.index[idim];
int end = theCellMax.index[idim];
for (int i=start; i <= end; i++) {
const Cell_IndexType aStart = theCellMin.index[idim];
const Cell_IndexType anEnd = theCellMax.index[idim];
for (Cell_IndexType i = aStart; i <= anEnd; ++i)
{
theCell.index[idim] = i;
if ( idim ) // recurse
{
iterateInspect (idim-1, theCell, theCellMin, theCellMax, theInspector);
}
else // inspect this cell
{
inspect (theCell, theInspector);
}
}
}
+10 -4
View File
@@ -145,21 +145,27 @@ Standard_Integer NCollection_UBTreeFiller<TheObjType,TheBndType>::Fill ()
Standard_Integer i, nbAdd = mySeqPtr.Length();
// Fisher-Yates randomization
if (myIsFullRandom)
for (i = nbAdd; i > 0; i--) {
unsigned int ind = myRandGen();
{
for (i = nbAdd; i > 0; i--)
{
unsigned int ind = (unsigned int )myRandGen();
ind = ind % i;
const ObjBnd& aObjBnd = mySeqPtr(ind);
myTree.Add (aObjBnd.myObj, aObjBnd.myBnd);
mySeqPtr(ind) = mySeqPtr(i-1);
}
}
else
for (i = nbAdd; i > 0; i--) {
unsigned int ind = myRandGen();
{
for (i = nbAdd; i > 0; i--)
{
unsigned int ind = (unsigned int )myRandGen();
ind = i - (ind % i) - 1;
const ObjBnd& aObjBnd = mySeqPtr(ind);
myTree.Add (aObjBnd.myObj, aObjBnd.myBnd);
mySeqPtr(ind) = mySeqPtr(i-1);
}
}
mySeqPtr.Clear();
return nbAdd;
}
+14 -14
View File
@@ -216,20 +216,20 @@ private:
private: //! @name unicode magic numbers
static const unsigned char UTF8_BYTES_MINUS_ONE[256];
static const unsigned long offsetsFromUTF8[6];
static const unsigned char UTF8_FIRST_BYTE_MARK[7];
static const unsigned long UTF8_BYTE_MASK;
static const unsigned long UTF8_BYTE_MARK;
static const unsigned long UTF16_SURROGATE_HIGH_START;
static const unsigned long UTF16_SURROGATE_HIGH_END;
static const unsigned long UTF16_SURROGATE_LOW_START;
static const unsigned long UTF16_SURROGATE_LOW_END;
static const unsigned long UTF16_SURROGATE_HIGH_SHIFT;
static const unsigned long UTF16_SURROGATE_LOW_BASE;
static const unsigned long UTF16_SURROGATE_LOW_MASK;
static const unsigned long UTF32_MAX_BMP;
static const unsigned long UTF32_MAX_LEGAL;
static const unsigned char UTF8_BYTES_MINUS_ONE[256];
static const Standard_Utf32Char offsetsFromUTF8[6];
static const unsigned char UTF8_FIRST_BYTE_MARK[7];
static const Standard_Utf32Char UTF8_BYTE_MASK;
static const Standard_Utf32Char UTF8_BYTE_MARK;
static const Standard_Utf32Char UTF16_SURROGATE_HIGH_START;
static const Standard_Utf32Char UTF16_SURROGATE_HIGH_END;
static const Standard_Utf32Char UTF16_SURROGATE_LOW_START;
static const Standard_Utf32Char UTF16_SURROGATE_LOW_END;
static const Standard_Utf32Char UTF16_SURROGATE_HIGH_SHIFT;
static const Standard_Utf32Char UTF16_SURROGATE_LOW_BASE;
static const Standard_Utf32Char UTF16_SURROGATE_LOW_MASK;
static const Standard_Utf32Char UTF32_MAX_BMP;
static const Standard_Utf32Char UTF32_MAX_LEGAL;
private: //! @name private fields
+12 -12
View File
@@ -54,7 +54,7 @@ const unsigned char NCollection_UtfIterator<Type>::UTF8_BYTES_MINUS_ONE[256] =
//! This table contains as many values as there might be trailing bytes
//! in a UTF-8 sequence.
template<typename Type>
const unsigned long NCollection_UtfIterator<Type>::offsetsFromUTF8[6] =
const Standard_Utf32Char NCollection_UtfIterator<Type>::offsetsFromUTF8[6] =
{
0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL
@@ -95,17 +95,17 @@ inline void NCollection_UtfIterator<Type>::readUTF8()
}
// magic numbers
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF8_BYTE_MASK = 0xBF;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF8_BYTE_MARK = 0x80;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF16_SURROGATE_HIGH_START = 0xD800;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF16_SURROGATE_HIGH_END = 0xDBFF;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_START = 0xDC00;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_END = 0xDFFF;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF16_SURROGATE_HIGH_SHIFT = 10;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_BASE = 0x0010000UL;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_MASK = 0x3FFUL;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF32_MAX_BMP = 0x0000FFFFUL;
template<typename Type> const unsigned long NCollection_UtfIterator<Type>::UTF32_MAX_LEGAL = 0x0010FFFFUL;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF8_BYTE_MASK = 0xBF;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF8_BYTE_MARK = 0x80;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_HIGH_START = 0xD800;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_HIGH_END = 0xDBFF;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_START = 0xDC00;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_END = 0xDFFF;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_HIGH_SHIFT = 10;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_BASE = 0x0010000UL;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_MASK = 0x3FFUL;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF32_MAX_BMP = 0x0000FFFFUL;
template<typename Type> const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF32_MAX_LEGAL = 0x0010FFFFUL;
// =======================================================================
// function : readUTF16