oxc-project
json-strip-comments
BlogDocsChangelog

perf: simplify state machine and eliminate code duplication

#117Closed
Comparing
perf/simplify-state-machine
(
fb3bf7a
) with
main
(
b907e37
)
CodSpeed Performance Gauge
-68%
Improvements
2
Regressions
2

Benchmarks

Failed

large_with_comments
benches/strip.rs::strip::bench
Regression
CodSpeed Performance Gauge
-13%
58.2 µs67 µs
tsconfig
benches/strip.rs::strip::bench
Regression
CodSpeed Performance Gauge
-68%
19.2 µs60.1 µs

Improved

minimal_comments
benches/strip.rs::strip::bench
CodSpeed Performance Gauge
+24%
2.4 µs2 µs
no_comments
benches/strip.rs::strip::bench
CodSpeed Performance Gauge
+15%
3.9 µs3.4 µs

Commits

Click on a commit to change the comparison range
Base
main
b907e37
-68.15%
feat: preserve newlines in comments and port sindresorhus tests Changes to comment handling: - Preserve \r and \n characters inside block comments (InBlockComment, MaybeCommentEnd states) - Preserve \r characters in line comments (InLineComment state) - This matches sindresorhus/strip-json-comments behavior and improves readability Test additions (13 new tests from sindresorhus/strip-json-comments): - sindresorhus_replace_comments_with_whitespace - sindresorhus_doesnt_strip_comments_inside_strings - sindresorhus_consider_escaped_slashes - sindresorhus_line_endings_no_comments - sindresorhus_line_endings_single_line_comment - sindresorhus_line_endings_single_line_block_comment - sindresorhus_line_endings_multi_line_block_comment - sindresorhus_line_endings_works_at_eof - sindresorhus_handles_weird_escaping - sindresorhus_strips_trailing_commas - sindresorhus_strips_trailing_commas_with_comments - sindresorhus_handles_malformed_block_comments - sindresorhus_handles_non_breaking_space All 57 tests (54 integration + 3 doc tests) passing. Ported from: https://github.com/sindresorhus/strip-json-comments/blob/main/test.js 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
fb3bf7a
1 day ago
by Boshen
© 2025 CodSpeed Technology
Home Terms Privacy Docs