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

Avoid unnecessary Allocations and Copys #4

Open
TobiasWallner opened this issue Sep 26, 2021 · 1 comment
Open

Avoid unnecessary Allocations and Copys #4

TobiasWallner opened this issue Sep 26, 2021 · 1 comment

Comments

@TobiasWallner
Copy link

You are using a lot of std::string types and always copy them. Consider using const char* pointer since you are only using raw literal strings. This will avoid unnecessary copys and allocations (this of course depends on the implementation of std::string and if its using short string optimisation)

And I took a deeper look at your code. Why are you not just using an enum value that already has the value needed for the win32 api? Something like

enum class hue {black = 0, .... }

Then you would just need to overload the stream operator for the enum.

@Patrix9999
Copy link

Hi, i know that many years have past since this issue has been opened, but i've decided recently to make my own version of this library using your suggestions:
https://github.com/Patrix9999/console-color

Maybe this will help someone.

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

No branches or pull requests

2 participants