Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of TestReportHandler and TreePrinter for Improved Code Quality and performance optimization #57

Merged

Conversation

neewrobert
Copy link
Contributor

This pull request includes a series of refactors that improve the readability, performance, and maintainability of the TestReportHandler and TreePrinter classes.

Key Refactors:

  • Replaced synchronizedMap with ConcurrentHashMap in TestReportHandler for better concurrency handling.

  • Simplified the logic for handling and printing test reports in both TestReportHandler and TreePrinter.

  • Streamlined conditions and removed redundant code to enhance code clarity and reduce complexity.

  • Minor formatting and syntax improvements for consistency and adherence to coding standards.

This commit refactors the TestReportHandler class to enhance its concurrency handling and simplify its code structure. These changes do not introduce any new functionality but focus on improving the overall performance, readability, and maintainability of the code.

Key Changes:
Concurrent Collection Usage:

Replaced synchronizedMap(new HashMap<>()) with ConcurrentHashMap for classNames, classEntries, and testEntries.
Why: ConcurrentHashMap is more efficient for concurrent operations, reducing the potential for thread contention and improving performance in multi-threaded environments.
Streamlined Collection Initialization:

Simplified the initialization and population of the classEntries map using computeIfAbsent and direct add() method instead of the previous computeIfPresent.
Why: This reduces the complexity of the code, making it more straightforward and easier to maintain.
Optimized String Handling:

Refactored the hasNestedTests(ReportEntry reportEntry) method to use anyMatch instead of filter followed by count.
Why: anyMatch is more efficient for this use case as it short-circuits when a match is found, improving the method’s performance and readability.
General Code Cleanup:

Adjusted import statements and fixed minor formatting issues, such as spacing and line breaks, to adhere to coding standards.
@neewrobert neewrobert changed the base branch from develop to master August 15, 2024 19:48
@neewrobert neewrobert force-pushed the small-performance-optimization branch from 4c9f057 to b06fc14 Compare August 27, 2024 12:45
@neewrobert neewrobert force-pushed the small-performance-optimization branch from b06fc14 to 13d2c9b Compare August 27, 2024 12:52
Copy link
Owner

@fabriciorby fabriciorby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fabriciorby fabriciorby merged commit dbab2d4 into fabriciorby:master Aug 27, 2024
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.

2 participants