removing old style casts and unused parameters and fixed unsafe float

comparisons
This commit is contained in:
DennisOSRM 2012-09-19 11:46:41 +02:00
parent 5423cff7a8
commit 71d184c39b
2 changed files with 24 additions and 23 deletions

View File

@ -235,7 +235,7 @@ public:
++mCurrentSize; ++mCurrentSize;
} }
inline void reserve(const size_t new_size) const { inline void reserve(const size_t) const {
//don't do anything //don't do anything
} }
@ -266,7 +266,7 @@ public:
} }
inline iterator begin() { inline iterator begin() {
return iterator((size_t)0, mBucketList); return iterator(static_cast<size_t>(0), mBucketList);
} }
inline iterator end() { inline iterator end() {
@ -274,7 +274,7 @@ public:
} }
inline deallocation_iterator dbegin() { inline deallocation_iterator dbegin() {
return deallocation_iterator((size_t)0, mBucketList); return deallocation_iterator(static_cast<size_t>(0), mBucketList);
} }
inline deallocation_iterator dend() { inline deallocation_iterator dend() {
@ -282,7 +282,7 @@ public:
} }
inline const_iterator begin() const { inline const_iterator begin() const {
return const_iterator((size_t)0, mBucketList); return const_iterator(static_cast<size_t>(0), mBucketList);
} }
inline const_iterator end() const { inline const_iterator end() const {

View File

@ -23,6 +23,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cfloat>
#include <cmath> #include <cmath>
#include <fstream> #include <fstream>
#include <limits> #include <limits>
@ -84,7 +85,7 @@ public:
void OpenIndexFiles() { void OpenIndexFiles() {
assert(ramInFile.is_open()); assert(ramInFile.is_open());
ramInFile.read((char*)&ramIndexTable[0], sizeof(unsigned long)*1024*1024); ramInFile.read(static_cast<char*>(static_cast<void*>(&ramIndexTable[0]) ), sizeof(unsigned long)*1024*1024);
ramInFile.close(); ramInFile.close();
} }
@ -187,7 +188,7 @@ public:
smallestEdge = candidate; smallestEdge = candidate;
//} else if(tmpDist < dist) { //} else if(tmpDist < dist) {
//INFO("a) ignored " << candidate.edgeBasedNode << " at distance " << std::fabs(dist - tmpDist)); //INFO("a) ignored " << candidate.edgeBasedNode << " at distance " << std::fabs(dist - tmpDist));
} else if(DoubleEpsilonCompare(dist, tmpDist) && 1 == std::abs((int)candidate.edgeBasedNode-(int)resultNode.edgeBasedNode)) { } else if(DoubleEpsilonCompare(dist, tmpDist) && 1 == std::abs(static_cast<int>(candidate.edgeBasedNode)-static_cast<int>(resultNode.edgeBasedNode) )) {
resultNode.weight2 = candidate.weight; resultNode.weight2 = candidate.weight;
//INFO("b) " << candidate.edgeBasedNode << ", dist: " << tmpDist); //INFO("b) " << candidate.edgeBasedNode << ", dist: " << tmpDist);
} }
@ -343,7 +344,7 @@ private:
indexIntoTmpBuffer += FlushEntriesWithSameFileIndexToBuffer(entriesWithSameFileIndex, tmpBuffer, indexIntoTmpBuffer); indexIntoTmpBuffer += FlushEntriesWithSameFileIndexToBuffer(entriesWithSameFileIndex, tmpBuffer, indexIntoTmpBuffer);
assert(entriesWithSameFileIndex.size() == 0); assert(entriesWithSameFileIndex.size() == 0);
indexOutFile.write((char *)&cellIndex[0],32*32*sizeof(unsigned long)); indexOutFile.write(static_cast<char*>(static_cast<void*>(&cellIndex[0])),32*32*sizeof(unsigned long));
numberOfWrittenBytes += 32*32*sizeof(unsigned long); numberOfWrittenBytes += 32*32*sizeof(unsigned long);
//write contents of tmpbuffer to disk //write contents of tmpbuffer to disk
@ -366,12 +367,12 @@ private:
} }
//write length of bucket //write length of bucket
memcpy((char*)&(tmpBuffer[index+counter]), (char *)&lengthOfBucket, sizeof(lengthOfBucket)); memcpy(static_cast<char*>(static_cast<void*>(&(tmpBuffer[index+counter]))), static_cast<char*>(static_cast<void*>(&lengthOfBucket)), sizeof(lengthOfBucket));
counter += sizeof(lengthOfBucket); counter += sizeof(lengthOfBucket);
BOOST_FOREACH(const GridEntry & entry, vectorWithSameFileIndex) { BOOST_FOREACH(const GridEntry & entry, vectorWithSameFileIndex) {
char * data = (char *)&(entry.edge); char * data = static_cast<char*>(static_cast<void*>(&(entry.edge) ));
memcpy((char*)&(tmpBuffer[index+counter]), data, sizeof(entry.edge)); memcpy(static_cast<char*>(static_cast<void*>(&(tmpBuffer[index+counter]) )), data, sizeof(entry.edge));
counter += sizeof(entry.edge); counter += sizeof(entry.edge);
} }
//Freeing data //Freeing data
@ -398,7 +399,7 @@ private:
//only read the single necessary cell index //only read the single necessary cell index
localStream->seekg(startIndexInFile+(enumeratedIndex*sizeof(unsigned long))); localStream->seekg(startIndexInFile+(enumeratedIndex*sizeof(unsigned long)));
unsigned long fetchedIndex = 0; unsigned long fetchedIndex = 0;
localStream->read((char*) &fetchedIndex, sizeof(unsigned long)); localStream->read(static_cast<char*>( static_cast<void*>(&fetchedIndex)), sizeof(unsigned long));
if(fetchedIndex == ULONG_MAX) { if(fetchedIndex == ULONG_MAX) {
return; return;
@ -408,9 +409,9 @@ private:
unsigned lengthOfBucket; unsigned lengthOfBucket;
unsigned currentSizeOfResult = result.size(); unsigned currentSizeOfResult = result.size();
localStream->seekg(position); localStream->seekg(position);
localStream->read((char *)&(lengthOfBucket), sizeof(unsigned)); localStream->read(static_cast<char*>( static_cast<void*>(&(lengthOfBucket))), sizeof(unsigned));
result.resize(currentSizeOfResult+lengthOfBucket); result.resize(currentSizeOfResult+lengthOfBucket);
localStream->read((char *)&result[currentSizeOfResult], lengthOfBucket*sizeof(_GridEdge)); localStream->read(static_cast<char*>( static_cast<void*>(&result[currentSizeOfResult])), lengthOfBucket*sizeof(_GridEdge));
} }
@ -434,7 +435,7 @@ private:
} }
localStream->seekg(startIndexInFile); localStream->seekg(startIndexInFile);
localStream->read((char*) cellIndex, 32*32*sizeof(unsigned long)); localStream->read(static_cast<char*>(static_cast<void*>( cellIndex)), 32*32*sizeof(unsigned long));
assert(cellMap.find(fileIndex) != cellMap.end()); assert(cellMap.find(fileIndex) != cellMap.end());
if(cellIndex[cellMap[fileIndex]] == ULONG_MAX) { if(cellIndex[cellMap[fileIndex]] == ULONG_MAX) {
return; return;
@ -444,9 +445,9 @@ private:
unsigned lengthOfBucket; unsigned lengthOfBucket;
unsigned currentSizeOfResult = result.size(); unsigned currentSizeOfResult = result.size();
localStream->seekg(position); localStream->seekg(position);
localStream->read((char *)&(lengthOfBucket), sizeof(unsigned)); localStream->read(static_cast<char*>(static_cast<void*>(&(lengthOfBucket))), sizeof(unsigned));
result.resize(currentSizeOfResult+lengthOfBucket); result.resize(currentSizeOfResult+lengthOfBucket);
localStream->read((char *)&result[currentSizeOfResult], lengthOfBucket*sizeof(_GridEdge)); localStream->read(static_cast<char*>(static_cast<void*>(&result[currentSizeOfResult])), lengthOfBucket*sizeof(_GridEdge));
} }
inline void AddEdge(const _GridEdge & edge) { inline void AddEdge(const _GridEdge & edge) {
@ -461,14 +462,14 @@ private:
inline double ComputeDistance(const _Coordinate& inputPoint, const _Coordinate& source, const _Coordinate& target, _Coordinate& nearest, double *r) { inline double ComputeDistance(const _Coordinate& inputPoint, const _Coordinate& source, const _Coordinate& target, _Coordinate& nearest, double *r) {
const double x = (double)inputPoint.lat; const double x = static_cast<double>(inputPoint.lat);
const double y = (double)inputPoint.lon; const double y = static_cast<double>(inputPoint.lon);
const double a = (double)source.lat; const double a = static_cast<double>(source.lat);
const double b = (double)source.lon; const double b = static_cast<double>(source.lon);
const double c = (double)target.lat; const double c = static_cast<double>(target.lat);
const double d = (double)target.lon; const double d = static_cast<double>(target.lon);
double p,q,mX,nY; double p,q,mX,nY;
if(c != a){ if(fabs(a-c) < FLT_EPSILON){
const double m = (d-b)/(c-a); // slope const double m = (d-b)/(c-a); // slope
// Projection of (x,y) on line joining (a,b) and (c,d) // Projection of (x,y) on line joining (a,b) and (c,d)
p = ((x + (m*y)) + (m*m*a - m*b))/(1. + m*m); p = ((x + (m*y)) + (m*m*a - m*b))/(1. + m*m);