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

Comprehensive Refactoring of Protocol Handlers for Enhanced Performance and Readability #1221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

merttozer
Copy link

This pull request introduces significant refactoring across three key components of the Hazelcast C++ client’s protocol handling: ClientMessageBuilder.h, list_cn_fixed_size_codec.h, and sql_page_codec.h. These changes leverage modern C++11 features to optimize performance, enhance readability, and improve error handling.

Detailed Changes:

1. ClientMessageBuilder.h:

  • Redundant Checks: Simplified control flow by removing redundant checks, making the code easier to follow.
  • Fragment Handling: Broke complex message fragmentation logic into smaller, more manageable functions.
  • Duplication Reduction: Introduced helper functions to eliminate duplicated message completion checks.
  • Naming Conventions: Improved variable and method names for greater clarity and maintainability.

2. list_cn_fixed_size_codec.h:

  • Vector Initialization: Used std::fill to initialize vectors for the NULL_ONLY case, optimizing performance.
  • Range-Based Loops: Implemented range-based for loops to simplify vector element modifications.

3. sql_page_codec.h:

  • Vector Capacity Management: Utilized reserve to pre-allocate memory for vectors, reducing the need for reallocation.
  • Range-Based Loops: Employed range-based for loops to streamline iteration over containers.
  • Efficient Element Insertion: Used emplace_back to construct elements in place, enhancing performance.
  • Explicit Null Handling: Added explicit handling for null values in vectors to maintain alignment and integrity.

Benefits:

  • Performance Improvements: Reduced memory and processing overhead across multiple components.
  • Increased Readability and Maintainability: Cleaner, more maintainable codebase due to modern C++ practices and clearer naming conventions.
  • Enhanced Reliability and Safety: More robust error handling and safer memory management.

…_codec for improved efficiency and readability using C++11 features
@devOpsHazelcast
Copy link
Contributor

devOpsHazelcast commented Apr 19, 2024

CLA assistant check
All committers have signed the CLA.

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.

None yet

2 participants