-
-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving code efficiency by errors from cppcheck #1369
Changes from 4 commits
79eab9e
171ae1b
1dda8a5
2339bab
68d64b9
7dc0699
39377a1
271779c
e274319
d9a5bc4
b8dfd52
196e78d
f3ad4b6
b9f6d61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,15 +44,18 @@ class ArrayRefContainer | |
explicit ArrayRefContainer(const size_t n, | ||
const ValueType& value = ValueType()) | ||
: m_ref(1), data(n, value) | ||
{} | ||
{ | ||
} | ||
|
||
ArrayRefContainer(const ArrayRefContainer& other) : m_ref(1), data(other.data) | ||
{} | ||
{ | ||
} | ||
|
||
template <typename InputIterator> | ||
ArrayRefContainer(InputIterator first, InputIterator last) | ||
: m_ref(1), data(first, last) | ||
{} | ||
{ | ||
} | ||
|
||
// Increment the reference count. | ||
void reref() { ++m_ref; } | ||
|
@@ -118,19 +121,18 @@ class Array | |
|
||
explicit Array(const size_t n, const ValueType& value = ValueType()) | ||
: d(new Container(n, value)) | ||
{} | ||
{ | ||
} | ||
|
||
template <typename InputIterator> | ||
Array(InputIterator first, InputIterator last) : d(new Container(first, last)) | ||
{} | ||
|
||
/** Copy constructor, note the copy made of the internal data of other. */ | ||
Array(const Array& other) | ||
{ | ||
other.d->reref(); | ||
d = other.d; | ||
} | ||
|
||
/** Copy constructor, note the copy made of the internal data of other. */ | ||
Array(const Array& other) : d(new Container(*other.d)) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we don't want to do this. The Array class is copy-on-write. Please remove and/or tell cppcheck to ignore this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
//'d' is allocated new memory and a deep copy is one | ||
|
||
~Array(); | ||
|
||
/** | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this commit somehow has message from the previous commit, but changes in it are for the just next commit about removing unused private function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also used clang-format on the 2 files.