• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nlohmann / json / 40067233414
95%

Build:
DEFAULT BRANCH: develop
Ran 24 Oct 2026 10:04AM UTC
Jobs 1
Files 61
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

24 Oct 2026 05:41AM UTC coverage: 95.194% (-0.02%) from 95.21%
40067233414

push

github

web-flow
Make the DOM parser cheaper per container and per member (#5882)

* Reserve the parser's nesting stack once

The stack of open arrays and objects was a std::vector<std::uint8_t> that
allocated at the first push_back and then reallocated at 1, 2, 4, 8 bytes,
so a document nested four levels deep made four allocations before it
parsed a value. A document that starts with a container now reserves 32
levels in one allocation; deeper documents grow as before. The loop that
reads the tokens is the code it was, so large documents are not affected
(a stack object with its own storage, and a reserve at every container,
both cost the token loop instructions or cycles).

Fixed cost of parsing a 124-byte object (macOS instructions): accept
-7.6 %, DOM -2.5 %; no change for a single number.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* Build arrays of the DOM parser in one exact-size allocation

Reading an array of unknown length appended its elements to a std::vector
one at a time, so a small array reallocated (and moved its elements) at
sizes 1, 2, 4, ... The DOM SAX parser now collects the elements of arrays
whose length is unknown on one stack shared by all open arrays and moves
them into an array of exactly the right size when the closing bracket
arrives. An array that grows past 16 elements switches to appending to its
own vector, so large arrays pay no second copy. Binary formats, which
announce the length, and builds with JSON_DIAGNOSTICS or
JSON_DIAGNOSTIC_POSITIONS (whose values need their final place from the
start) keep storing into the array directly.

The stacks of open containers are reserved on first use instead of growing
from one element.

The binary readers get a DOM parser of their own, json_sax_dom_binary_parser:
it is the plain parser that stores every value directly in its container
(the code the readers used before). Their containers announce their size, so
the bookkeeping of the collecting parser (frame entries, the destination of a
... (continued)

18432 of 52785 branches covered (34.92%)

374 of 379 new or added lines in 4 files covered. (98.68%)

214 existing lines in 5 files now uncovered.

14539 of 15273 relevant lines covered (95.19%)

5357110.07 hits per line

Uncovered Changes

Lines Coverage ∆ File
5
99.0
-0.41% include/nlohmann/detail/input/json_sax.hpp

Coverage Regressions

Lines Coverage ∆ File
141
59.83
4.0% include/nlohmann/detail/view/builder.hpp
53
88.11
-3.23% include/nlohmann/detail/view/serializer.hpp
13
97.65
-0.65% include/nlohmann/json_view.hpp
5
84.29
-3.59% include/nlohmann/detail/view/simd.hpp
2
98.25
-0.03% include/nlohmann/detail/view/object_index.hpp
Jobs
ID Job ID Ran Files Coverage
1 40067233414.1 24 Oct 2026 10:04AM UTC 61
95.19
GitHub Action Run
Source Files on build 40067233414
  • Tree
  • List 61
  • Changed 14
  • Source Changed 14
  • Coverage Changed 13
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #40067233414
  • 9c50bdd1 on github
  • Prev Build on develop (#39904375107)
  • Next Build on develop (#40109345980)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc