Skip to content

Conversation

@malkovitc
Copy link

Summary

Fixes #472

Performance and memory optimizations for MessageDeduplicator:

Changes:

  • Make Entry struct Equatable for better testability
  • Smarter batch removal: remove down to 75% of maxCount instead of fixed 100 items, improving amortization of cleanup cost
  • Reuse Date instance in isDuplicate() to reduce allocations
  • Add documentation comments for public methods
  • Improve memory capacity management in cleanup() - only shrink when array is significantly oversized AND count is low

Benefits:

  • Fewer object allocations per message
  • More efficient memory management
  • Better cache locality with optimized removal strategy
  • 100% backward compatible - same public API

Test plan

  • Build succeeds
  • Run existing deduplication tests
  • Verify no regressions in message handling

evgeniy.chernomortsev added 2 commits December 9, 2025 14:50
allowBluetoothHFP is not available on iOS Simulator, causing build
failures. Use conditional compilation to exclude this option when
building for simulator while keeping it for device builds.
- Make Entry struct Equatable for better testability
- Remove down to 75% of maxCount instead of fixed 100 items for better
  amortization of cleanup cost
- Reuse Date instance to reduce allocations in isDuplicate()
- Add documentation comments for public methods
- Improve memory capacity management in cleanup()
@malkovitc malkovitc closed this by deleting the head repository Dec 10, 2025
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.

feat: optimize MessageDeduplicator performance and memory management

1 participant