aboutsummaryrefslogtreecommitdiff
path: root/src/lib_json/json_value.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib_json/json_value.cpp')
-rw-r--r--src/lib_json/json_value.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp
index 0872ff5..aa2b744 100644
--- a/src/lib_json/json_value.cpp
+++ b/src/lib_json/json_value.cpp
@@ -259,7 +259,7 @@ Value::CZString::CZString(const CZString& other) {
storage_.length_ = other.storage_.length_;
}
-Value::CZString::CZString(CZString&& other)
+Value::CZString::CZString(CZString&& other) noexcept
: cstr_(other.cstr_), index_(other.index_) {
other.cstr_ = nullptr;
}
@@ -285,7 +285,7 @@ Value::CZString& Value::CZString::operator=(const CZString& other) {
return *this;
}
-Value::CZString& Value::CZString::operator=(CZString&& other) {
+Value::CZString& Value::CZString::operator=(CZString&& other) noexcept {
cstr_ = other.cstr_;
index_ = other.index_;
other.cstr_ = nullptr;
@@ -433,7 +433,7 @@ Value::Value(const Value& other) {
dupMeta(other);
}
-Value::Value(Value&& other) {
+Value::Value(Value&& other) noexcept {
initBasic(nullValue);
swap(other);
}
@@ -448,7 +448,7 @@ Value& Value::operator=(const Value& other) {
return *this;
}
-Value& Value::operator=(Value&& other) {
+Value& Value::operator=(Value&& other) noexcept {
other.swap(*this);
return *this;
}
@@ -912,7 +912,8 @@ void Value::resize(ArrayIndex newSize) {
if (newSize == 0)
clear();
else if (newSize > oldSize)
- this->operator[](newSize - 1);
+ for (ArrayIndex i = oldSize; i < newSize; ++i)
+ (*this)[i];
else {
for (ArrayIndex index = newSize; index < oldSize; ++index) {
value_.map_->erase(index);
@@ -1373,14 +1374,15 @@ bool Value::isObject() const { return type() == objectValue; }
Value::Comments::Comments(const Comments& that)
: ptr_{cloneUnique(that.ptr_)} {}
-Value::Comments::Comments(Comments&& that) : ptr_{std::move(that.ptr_)} {}
+Value::Comments::Comments(Comments&& that) noexcept
+ : ptr_{std::move(that.ptr_)} {}
Value::Comments& Value::Comments::operator=(const Comments& that) {
ptr_ = cloneUnique(that.ptr_);
return *this;
}
-Value::Comments& Value::Comments::operator=(Comments&& that) {
+Value::Comments& Value::Comments::operator=(Comments&& that) noexcept {
ptr_ = std::move(that.ptr_);
return *this;
}
@@ -1396,13 +1398,11 @@ String Value::Comments::get(CommentPlacement slot) const {
}
void Value::Comments::set(CommentPlacement slot, String comment) {
- if (!ptr_) {
+ if (slot >= CommentPlacement::numberOfCommentPlacement)
+ return;
+ if (!ptr_)
ptr_ = std::unique_ptr<Array>(new Array());
- }
- // check comments array boundry.
- if (slot < CommentPlacement::numberOfCommentPlacement) {
- (*ptr_)[slot] = std::move(comment);
- }
+ (*ptr_)[slot] = std::move(comment);
}
void Value::setComment(String comment, CommentPlacement placement) {