json-logic-java icon indicating copy to clipboard operation
json-logic-java copied to clipboard

Construct JSON path only on exceptional cases.

Open guidobrei opened this issue 2 months ago • 3 comments

This pull request addresses issue #63: Excessive object and memory allocations from string format operations during JSON logic evaluation.

Summary of Improvements

  • Optimized jsonPath Construction:
    Now, jsonPath is built only when exceptions are thrown, not on every evaluation step.
  • Reduced Usage of String.format:
    Frequent string formatting—previously responsible for a large portion of memory allocation—is now minimized.
  • Efficient String Manipulation:
    Refactored string handling within the evaluation logic for improved efficiency.
  • Decreased Unnecessary Object Creation:
    Memory profiles should reflect reduced object churn and overall improved allocation patterns.
  • No breaking changes: The public interfaces have not been changed. The change should not break any dependent library.

Benefits

  • Lower Memory Footprint:
    Dramatically reduces allocations related to string operations, easing runtime memory pressure.
  • Improved Performance:
    Faster evaluations due to fewer expensive object and string operations.
  • Better Scalability:
    Enhanced library stability and efficiency under heavy or high-throughput usage.
  • Targeted Exception Diagnostics:
    jsonPath remains available for error handling and diagnostics, but is computed only as needed.

guidobrei avatar Nov 12 '25 21:11 guidobrei