Skip to content

Perf improvements#1

Merged
robertjndw merged 3 commits intomainfrom
feat/perf-improvements
Feb 28, 2026
Merged

Perf improvements#1
robertjndw merged 3 commits intomainfrom
feat/perf-improvements

Conversation

@robertjndw
Copy link
Owner

This pull request introduces several improvements and optimizations across the codebase, focusing on performance, stricter type handling, and updated dependencies. The most significant changes include enhanced benchmarking documentation, Go version upgrades, performance optimizations in JSON diffing and pointer operations, improved unmarshalling robustness, and more efficient deep copying of JSON values.

Performance & Benchmarking Enhancements:

  • Added a comprehensive "Performance & Benchmarking" section to the README.md, detailing how to run and compare benchmarks, and describing benchmark coverage for contributors.

Dependency Updates:

  • Upgraded the Go version from 1.23 to 1.24 in go.mod and all relevant GitHub Actions workflow files (.github/workflows/compile_examples.yml, .github/workflows/test_go.yml). [1] [2] [3]

Performance Optimizations:

  • Optimized the diff function in create.go to use fast path comparisons for primitive types before falling back to deep equality checks, reducing overhead for common cases.
  • Improved the Pointer operations (Set, Remove, and String) in pointer.go by reducing redundant calls, pre-estimating string builder capacity, and using more efficient array manipulation. [1] [2] [3] [4] [5] [6]

Type Handling and Robustness:

  • Updated Operation.UnmarshalJSON in patch.go to strictly reject null values for string fields, preventing silent acceptance of invalid input and improving error messages.
  • Simplified jsonEqual in apply.go to assume caller-supplied values are already normalized, removing unnecessary normalization steps for performance.

Internal Utility Improvements:

  • Replaced the previous deep copy implementation in pointer.go with a recursive copy for maps and slices, avoiding the overhead of JSON serialization/deserialization.
  • Added fast-path checks for escaping and unescaping pointer tokens to avoid unnecessary string replacements when possible. [1] [2]

@robertjndw robertjndw merged commit 907b030 into main Feb 28, 2026
2 checks passed
@robertjndw robertjndw deleted the feat/perf-improvements branch February 28, 2026 10:27
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.

1 participant