Skip to content

Erase_at_pointer and related test#1161

Open
RoyBellingan wants to merge 1 commit into
boostorg:developfrom
RoyBellingan:erase_at_pointer
Open

Erase_at_pointer and related test#1161
RoyBellingan wants to merge 1 commit into
boostorg:developfrom
RoyBellingan:erase_at_pointer

Conversation

@RoyBellingan
Copy link
Copy Markdown

based on the suggestion in #1138

Splits the JSON Pointer via next_segment, then navigate to the parent with find_pointer, this avoid duplicating the walk_pointer logic.

…g#1138

Resolve the parent JSON Pointer by splitting the full pointer into a
parent prefix and last segment (via next_segment), then navigate to the
parent with find_pointer instead of duplicating the walk_pointer logic.
@cppalliance-bot
Copy link
Copy Markdown

An automated preview of the documentation is available at https://1161.json.prtest2.cppalliance.org/libs/json/doc/html/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-05-10 21:37:43 UTC

@cppalliance-bot
Copy link
Copy Markdown

GCOVR code coverage report https://1161.json.prtest2.cppalliance.org/gcovr/index.html
LCOV code coverage report https://1161.json.prtest2.cppalliance.org/genhtml/index.html
Coverage Diff Report https://1161.json.prtest2.cppalliance.org/diff-report/index.html

Build time: 2026-05-10 21:49:17 UTC

@codecov
Copy link
Copy Markdown

codecov Bot commented May 10, 2026

Codecov Report

❌ Patch coverage is 84.09091% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.86%. Comparing base (f299282) to head (675a94f).

Files with missing lines Patch % Lines
include/boost/json/impl/pointer.ipp 84.09% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1161      +/-   ##
===========================================
- Coverage    93.91%   93.86%   -0.05%     
===========================================
  Files           91       91              
  Lines         9262     9306      +44     
===========================================
+ Hits          8698     8735      +37     
- Misses         564      571       +7     
Files with missing lines Coverage Δ
include/boost/json/value.hpp 99.03% <ø> (ø)
include/boost/json/impl/pointer.ipp 97.56% <84.09%> (-2.44%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f299282...675a94f. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cppalliance-bot
Copy link
Copy Markdown

Comment on lines +549 to +551
value* parent = detail::walk_pointer(
*this,
parent_sv,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to just walk the entire pointer string and in object and array handlers update a value* parent variable (in the case of object you'd have to also store the key)? Then, after you finished walking:

  • parent is a pointer to array, object or nullptr (you can rely on that later in the switch case).
  • You don't have to check for missing slash manually.
  • You don't have to walk the pointer string twice.
  • You don't have to do manually look up the pointed-to element in the parent.

[]( array& arr, std::size_t index, system::error_code& ec ) -> value*
{
if( ec )
return nullptr;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not covered by tests. See here: https://1161.json.prtest2.cppalliance.org/diff-report/include/boost/json/impl/pointer.ipp.html. There are also other lines that miss coverage.

}
return false;
}
default: {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://1161.json.prtest2.cppalliance.org/diff-report/include/boost/json/impl/pointer.ipp.html#NL593

I am pretty sure this switch case is unreachable, so replace it with

default: // LCOV_EXCL_LINE
   BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants