Skip to content

Commit

Permalink
allow nullptr when not care the removed array value
Browse files Browse the repository at this point in the history
  • Loading branch information
yantaozhao committed Jul 3, 2018
1 parent 80bc776 commit e32ee47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ Json::Value obj_value(Json::objectValue); // {}
/** \brief Remove the indexed array element.
O(n) expensive operations.
Update 'removed' if removed.
Update 'removed' iff removed.
\return true if removed (no exceptions)
*/
bool removeIndex(ArrayIndex index, Value* removed);
Expand Down
3 changes: 2 additions & 1 deletion src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,8 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) {
if (it == value_.map_->end()) {
return false;
}
*removed = it->second;
if (removed)
*removed = it->second;
ArrayIndex oldSize = size();
// shift left all items left, into the place of the "removed"
for (ArrayIndex i = index; i < (oldSize - 1); ++i) {
Expand Down

0 comments on commit e32ee47

Please sign in to comment.