imraklr / BluZoneLock

An application to lock your PC workstation remotely using your Bluetooth-connected phone.
0 stars 0 forks source link

Client(Windows Console Application): Inefficient and fixed size data sharing structure for page data sharing #23

Closed imraklr closed 3 months ago

imraklr commented 3 months ago

The following code snippet from PagesInfo.h has an inefficient structure for storing common shared data among all the pages:

/**
* @brief A structure for storing shared contents of header and body sections.
*/
struct Reusable {
    // The unique id of the content.
    short id;
    // The content.
    void* content;
};

/**
* @brief An instance of `std::shared_ptr<struct Reusable[]>` to store the shared contents 
* of header & body sections in a `struct Reusable` struct. It needs to be defined only 
* once. It could store anything from repeated strings in console output to a thread or an 
* object.
*/
extern std::shared_ptr<struct Reusable[]> pageSharedStuff;

Suggestion: Remove struct Reusable and use unordered_map with int for ID and void* as pointer to the content. Sample of what it should look like:

extern std::shared_ptr<unordered_map<int, void*>> pageSharedContent;

This will ensure that we are not limited by space and this gives a clear syntax to work with.