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

open-source-parsers / jsoncpp
90%
master: 90%

Build:
Build:
LAST BUILD BRANCH: refs/pull/1691/merge
DEFAULT BRANCH: master
Repo Added 18 Oct 2019 02:45AM UTC
Files 8
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

LAST BUILD ON BRANCH refs/tags/1.9.8-rc1
branch: refs/tags/1.9.8-rc1
CHANGE BRANCH
x
Reset
  • refs/tags/1.9.8-rc1
  • 00.11.0
  • 00.11.z
  • 1.9.2
  • 1.9.3
  • 1.9.4
  • 1.9.7
  • Add-project-status-to-README-to-set-expectations
  • BillyDonahue-avoid-isprint
  • BillyDonahue-patch-1
  • add-runtime-version
  • allow-dropped-placeholders
  • baylesj-patch-1
  • baylesj-patch-6
  • baylesj-patch-7
  • baylesj-patch-8
  • baylesj-patch-9
  • ci/bump-node24-actions
  • cmake-version
  • coverage
  • docs/remove-pkg-managers
  • drop_cpptl_support
  • feature-amalgamation
  • fix-cpp20-build
  • fix-cxx11-abi-break
  • fix-czstring
  • fix-fuzzer
  • fix-github-actions-warnings
  • fix-issue-1627
  • fix/cmake-dll-build-scope
  • fix/locale-number-parsing
  • fix/reader-dangling-ptr
  • fix/reject-control-chars
  • fix/string-view-abi
  • fixup-project-version-updater
  • fixup-tests
  • fuzzer-fix1
  • improve-formatting
  • improve-qualifier-support
  • inc
  • issue1591
  • json-dll-build
  • jsoncpp_test
  • master
  • members
  • patch-renu555
  • pre-v2.y.z
  • pypi
  • refs/pull/1214/merge
  • refs/pull/1339/merge
  • refs/pull/1383/merge
  • refs/pull/1409/merge
  • refs/pull/1419/merge
  • refs/pull/1424/merge
  • refs/pull/1435/merge
  • refs/pull/1448/merge
  • refs/pull/1457/merge
  • refs/pull/1462/merge
  • refs/pull/1467/merge
  • refs/pull/1478/merge
  • refs/pull/1479/merge
  • refs/pull/1480/merge
  • refs/pull/1486/merge
  • refs/pull/1491/merge
  • refs/pull/1499/merge
  • refs/pull/1516/merge
  • refs/pull/1527/merge
  • refs/pull/1528/merge
  • refs/pull/1534/merge
  • refs/pull/1567/merge
  • refs/pull/1570/merge
  • refs/pull/1572/merge
  • refs/pull/1574/merge
  • refs/pull/1575/merge
  • refs/pull/1578/merge
  • refs/pull/1579/merge
  • refs/pull/1584/merge
  • refs/pull/1593/merge
  • refs/pull/1596/merge
  • refs/pull/1597/merge
  • refs/pull/1599/merge
  • refs/pull/1600/merge
  • refs/pull/1601/merge
  • refs/pull/1602/merge
  • refs/pull/1615/merge
  • refs/pull/1619/merge
  • refs/pull/1622/merge
  • refs/pull/1625/merge
  • refs/pull/1635/merge
  • refs/pull/1637/merge
  • refs/pull/1639/merge
  • refs/pull/1648/merge
  • refs/pull/1649/merge
  • refs/pull/1654/merge
  • refs/pull/1657/merge
  • refs/pull/1658/merge
  • refs/pull/1659/merge
  • refs/pull/1660/merge
  • refs/pull/1661/merge
  • refs/pull/1662/merge
  • refs/pull/1663/merge
  • refs/pull/1665/merge
  • refs/pull/1666/merge
  • refs/pull/1667/merge
  • refs/pull/1674/merge
  • refs/pull/1677/merge
  • refs/pull/1678/merge
  • refs/pull/1679/merge
  • refs/pull/1680/merge
  • refs/pull/1683/merge
  • refs/pull/1685/merge
  • refs/pull/1686/merge
  • refs/pull/1689/merge
  • refs/pull/1691/merge
  • refs/tags/1.9.6
  • refs/tags/1.9.7
  • revert-1662-fix/locale-number-parsing
  • revert-soversion-change
  • stack-depth
  • v1.9.3
  • version-header

14 Jun 2026 03:16AM UTC coverage: 89.949% (+0.005%) from 89.944%
27487810875

push

github

web-flow
fix: avoid quadratic re-scan of comments after a value (#1689)

* fix: avoid quadratic re-scan of comments after a value

OurReader::readComment() decides whether a comment should be attached to
the previous value (commentAfterOnSameLine) by scanning the input from the
end of that value up to the comment with containsNewLine(). lastValueEnd_
only advances when a new value is read, so a long run of comments after a
value (e.g. during error recovery, or a value followed by many comments)
made every comment re-scan the same growing prefix, giving O(n^2) parse
time. A jsoncpp_fuzzer testcase took ~18s for a 400KB input.

A comment can only ever be on the same line as the last value if no
newline separates them, and the gap to inspect only grows as further
comments are consumed, so once the gap has been examined for the first
comment it never needs to be examined again. Mark lastValueHasAComment_
after the first comment following a value so subsequent comments skip the
scan. Parsing the testcase drops from ~18s to ~56ms with identical output.

Add a regression test that parses a value followed by a large number of
trailing comments and requires it to complete well under a generous time
bound.

* test: assert linear comment scanning deterministically

Replace the wall-clock bound in the comment regression test with a
direct, deterministic assertion on work done. The parse output is
identical with and without the fix, so the only observable difference is
how much the parser scans; a time bound is also flaky under
valgrind/sanitizers/loaded CI.

Add an instrumentation counter for the bytes examined by
OurReader::containsNewLine, exposed via a JSON_API seam, and assert it
stays linear in the input (scanned < 4 * doc.size()) rather than
O(comments * gap). The counter is thread_local (no race during
concurrent parsing) and the increment is negligible, running only while
parsing comments. It is compiled unconditionally because the ABI
compatibility job builds the... (continued)

2201 of 2614 branches covered (84.2%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 1 file covered. (100.0%)

2605 of 2729 relevant lines covered (95.46%)

23441.29 hits per line

Relevant lines Covered
Build:
Build:
2729 RELEVANT LINES 2605 COVERED LINES
23441.29 HITS PER LINE
Source Files on refs/tags/1.9.8-rc1
  • Tree
  • List 8
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
27487810875 refs/tags/1.9.8-rc1 fix: avoid quadratic re-scan of comments after a value (#1689) * fix: avoid quadratic re-scan of comments after a value OurReader::readComment() decides whether a comment should be attached to the previous value (commentAfterOnSameLine) by scann... push 14 Jun 2026 04:04AM UTC web-flow github
89.95
See All Builds (766)
  • Repo on GitHub
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc