Browse Source

Removed invocations of memcpy in favour of std::copy as compilers will take care of optimizations.

tempestpy_adaptions
dehnert 12 years ago
parent
commit
05eaab7816
  1. 6
      src/models/GraphTransitions.h
  2. 5
      src/storage/BitVector.h
  3. 7
      src/storage/SquareSparseMatrix.h

6
src/models/GraphTransitions.h

@ -10,7 +10,7 @@
#include "src/storage/SquareSparseMatrix.h"
#include <string.h>
#include <algorithm>
namespace mrmc {
@ -92,7 +92,7 @@ private:
// First, we copy the index list from the sparse matrix as this will
// stay the same.
memcpy(this->stateIndications, transitionMatrix->getRowIndicationsPointer(), numberOfStates + 1);
std::copy(transitionMatrix->getRowIndicationsPointer(), transitionMatrix->getRowIndicationsPointer() + numberOfStates + 1, this->stateIndications);
// Now we can iterate over all rows of the transition matrix and record
// the target state.
@ -134,7 +134,7 @@ private:
// Create an array that stores the next index for each state. Initially
// this corresponds to the previously computed accumulated offsets.
uint_fast64_t* nextIndicesList = new uint_fast64_t[numberOfStates];
memcpy(nextIndicesList, stateIndications, numberOfStates * sizeof(uint_fast64_t));
std::copy(stateIndications, stateIndications + numberOfStates, nextIndicesList);
// Now we are ready to actually fill in the list of predecessors for
// every state. Again, we start by considering all but the last row.

5
src/storage/BitVector.h

@ -10,7 +10,6 @@
#include "src/exceptions/invalid_argument.h"
#include "src/exceptions/out_of_range.h"
#include <string.h>
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
@ -142,7 +141,7 @@ public:
BitVector(const BitVector &bv) : bucketCount(bv.bucketCount) {
LOG4CPLUS_WARN(logger, "Invoking copy constructor.");
bucketArray = new uint_fast64_t[bucketCount];
memcpy(bucketArray, bv.bucketArray, sizeof(uint_fast64_t) * bucketCount);
std::copy(bv.bucketArray, bv.bucketArray + bucketCount, bucketArray);
}
//! Destructor
@ -170,7 +169,7 @@ public:
// Copy over the elements from the old bit vector.
uint_fast64_t copySize = (newBucketCount <= bucketCount) ? newBucketCount : bucketCount;
memcpy(tempArray, bucketArray, sizeof(uint_fast64_t) * copySize);
std::copy(bucketArray, bucketArray + copySize, tempArray);
// Initialize missing values in the new bit vector.
for (uint_fast64_t i = copySize; i < bucketCount; ++i) {

7
src/storage/SquareSparseMatrix.h

@ -3,6 +3,7 @@
#include <exception>
#include <new>
#include <algorithm>
#include "boost/integer/integer_mask.hpp"
#include "src/exceptions/invalid_state.h"
@ -96,9 +97,9 @@ public:
}
// The elements that are not of the value type but rather the
// index type may be copied with memcpy.
memcpy(columnIndications, ssm.columnIndications, sizeof(columnIndications[0]) * nonZeroEntryCount);
memcpy(rowIndications, ssm.rowIndications, sizeof(rowIndications[0]) * (rowCount + 1));
// index type may be copied directly.
std::copy(ssm.columnIndications, ssm.columnIndications + nonZeroEntryCount, columnIndications);
std::copy(ssm.rowIndications, ssm.rowIndications + rowCount + 1, rowIndications);
}
}
}

Loading…
Cancel
Save