-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Expected Behavior
The newTopics() method should efficiently build and filter the topic collection by minimizing redundant iterations and clearly separating lookup, filtering, and removal steps. Duplicate topic removal logic should be efficient and readable, leveraging auxiliary data structures like maps for O(1) lookups.
Current Behavior
The current implementation uses nested loops with O(n²) time complexity, performing multiple iterations over topic collections and in-place removals within loops. This leads to reduced readability, potential performance overhead for larger topic sets, and increased maintenance complexity.
Context
This performance bottleneck affects application startup time when dealing with large topic configurations. The goal is to optimize the topic deduplication logic from O(n²) to O(n) complexity while maintaining code clarity.
Alternative approaches like end-to-end Stream API were considered, but the stepwise map-based approach better expresses the intent of each filtering stage.