Skip to content

Commit 7ec4353

Browse files
pcaspersjenkins
authored andcommitted
QPR-11984 back to memcpy()
1 parent 222b1e4 commit 7ec4353

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

QuantExt/qle/math/randomvariable.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Filter::Filter(const Filter& r) {
3737
constantData_ = r.constantData_;
3838
if (r.data_) {
3939
data_ = new bool[n_];
40-
std::copy(r.data_, r.data_ + n_, data_);
40+
std::memcpy(data_, r.data_, n_ * sizeof(bool));
4141
} else {
4242
data_ = nullptr;
4343
}
@@ -67,7 +67,7 @@ Filter& Filter::operator=(const Filter& r) {
6767
delete[] data_;
6868
data_ = new bool[r.n_];
6969
}
70-
std::copy(r.data_, r.data_ + n_, data_);
70+
std::memcpy(data_, r.data_, n_ * sizeof(bool));
7171
} else {
7272
if (data_) {
7373
delete[] data_;
@@ -253,7 +253,7 @@ RandomVariable::RandomVariable(const RandomVariable& r) {
253253
constantData_ = r.constantData_;
254254
if (r.data_) {
255255
data_ = new double[n_];
256-
std::copy(r.data_, r.data_ + n_, data_);
256+
std::memcpy(data_, r.data_, n_ * sizeof(double));
257257
} else {
258258
data_ = nullptr;
259259
}
@@ -285,7 +285,7 @@ RandomVariable& RandomVariable::operator=(const RandomVariable& r) {
285285
delete[] data_;
286286
data_ = new double[r.n_];
287287
}
288-
std::copy(r.data_, r.data_ + n_, data_);
288+
std::memcpy(data_, r.data_, n_ * sizeof(double));
289289
} else {
290290
if (data_) {
291291
delete[] data_;
@@ -339,7 +339,7 @@ RandomVariable::RandomVariable(const QuantLib::Array& array, const Real time) {
339339
time_ = time;
340340
if (n_ != 0) {
341341
data_ = new double[n_];
342-
std::copy(array.begin(), array.end(), data_);
342+
std::memcpy(data_, array.begin(), n_ * sizeof(double));
343343
}
344344
constantData_ = 0.0;
345345
}
@@ -356,7 +356,7 @@ void RandomVariable::copyToArray(QuantLib::Array& array) const {
356356
if (deterministic_)
357357
std::fill(array.begin(), array.end(), constantData_);
358358
else if (n_ != 0) {
359-
std::copy(data_, data_ + n_, array.begin());
359+
std::memcpy(array.begin(), data_, n_ * sizeof(double));
360360
}
361361
}
362362

0 commit comments

Comments
 (0)