Informations
Jump to content

Lorem Ipsum...

Click to Dismiss this Notification
Ładowanie danych...

Modernization And Optimization DynamicCharacterPtr Structure


Recommended Posts

  • Administrator

This code change introduces several significant improvements and enhancements:

  1. Function Pointers Usage: The original code used direct function calls like CHARACTER_MANAGER::Instance().FindByPID(id) and CHARACTER_MANAGER::Instance().Find(id) inside DynamicCharacterPtr::Get(). In the modified version, function pointers are used like manager.FindByPID(id) and manager.Find(id). This means the code has become more flexible and is no longer tightly coupled to a specific instance of CHARACTER_MANAGER.

  2. Usage of Constructors and Move Operators: In the modified version, default constructors were added, allowing for more elegant creation of DynamicCharacterPtr objects. Move operators were also added, increasing performance and enabling efficient memory management.

  3. Separation of Interface and Implementation: In the original code, functions were defined directly in the header file (char.h). In the modified version, the interface (DynamicCharacterPtr) is defined in the header file, and the function implementations are moved to the source file (char.cpp). This enhances code readability and makes it easier to maintain.

  4. Accessing Members through Methods: In the modified version, access to private members (is_pc and id) is done through public methods (IsPC(), GetID(), SetIsPC(), SetID()), ensuring better encapsulation and control over the data.

  5. Usage of default for Special Member Functions: The modified code uses default for special member functions, meaning these functions are automatically generated by the compiler. This eliminates the need for manually defining these functions, leading to more readable and safer code.

These changes make the code more readable, flexible, and easier to manage and maintain in the future. The optimizations introduced in the code also enhance its performance and safety.

 

char.cpp

Find:

This is the hidden content, please

Change To:

This is the hidden content, please

char.h

Find:

This is the hidden content, please

Change To:

This is the hidden content, please

 

Link to comment
Share on other sites


  • 100% changed the title to Modernization And Optimization DynamicCharacterPtr Structure

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

spacer.png

Disable AdBlock
The popup will be closed in 5 seconds...