presidio icon indicating copy to clipboard operation
presidio copied to clipboard

perf: optimize conflict resolution algorithm in AnonymizerEngine

Open Ray0907 opened this issue 1 month ago • 1 comments

Change Description

  • Replace O(n) list.remove() with O(1) set operations for tracking active indices
  • Use pop() instead of remove() in whitespace merge since prev_result is always last
  • Convert list comprehension to generator expression for short-circuit evaluation
  • Pre-compile regex pattern to avoid repeated compilation

Issue reference

Fixes #XX

Checklist

  • [x] I have reviewed the contribution guidelines
  • [x] I have signed the CLA (if required)
  • [x] My code includes unit tests
  • [x] All unit tests and lint checks pass locally
  • [ ] My PR contains documentation updates / additions if required

Ray0907 avatar Nov 29 '25 11:11 Ray0907

@microsoft-github-policy-service agree

Ray0907 avatar Nov 29 '25 11:11 Ray0907