schemagen: fix quadratic leading-zero strip in integer fallback #47

Merged
andrew merged 1 commits from weaselbot/weaseljson:weaselbot/issue-34 into main 2026-06-30 16:16:45 +00:00
Member

Closes #34

Closes #34
weaselbot added 1 commit 2026-06-30 16:09:35 +00:00
schemagen: fix quadratic leading-zero strip in integer fallback
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 51s
CI / pre-commit (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m32s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m26s
ceb16e5405
Replace the O(k^2) loop that erased leading zeros one byte at a time
from the front of a std::string with a single linear scan and one
erase(0, n) call.

Also adds regression tests for issue #34:
- correctness cases for numbers with leading fractional zeros
- a static check that the generated code no longer contains the
  quadratic pattern
- a large-input case (100k leading zeros) that reproduces the
  vulnerable shape

Closes #34
andrew merged commit e22bc039ae into main 2026-06-30 16:16:45 +00:00
andrew deleted branch weaselbot/issue-34 2026-06-30 16:16:45 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weaselab/weaseljson#47