-
-
Notifications
You must be signed in to change notification settings - Fork 621
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
Use perfect hash (gperf) for parsing color names #1848
Conversation
#ifdef BUILD_X11 | ||
unsigned long Colour::to_x11_color(Display *display, int screen, | ||
bool transparency, bool premultiply) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to x11-color.cc
where previous matching function was.
9a2ec7a
to
c69dcaf
Compare
cba15e6
to
8e07629
Compare
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
9f71a4a
to
f34b5dd
Compare
✅ Deploy Preview for conkyweb ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
e629fc3
to
e4d4e9b
Compare
Made CMake copy the file renamed in case gperf isn't available. This should prevent the compiler from finding stub before generated file. Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
e4d4e9b
to
5133193
Compare
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
This commit sounds good (so, thank you!) but just what does it mean for the writer of conkies? How should we give colour names now? Is the new system backwards compatible? |
Replaces X11 color name lookup with something that's easier to maintain.
Performance
Possibly faster than previous implementation - previous used binary search (
O(log n)
) on sorted color names, new uses a perfect hash (O(1)
).Extensibility
The main selling point of this PR is that it replaces code that was hard to extend with something where people can easily add their own colors.
While writing this PR, I realized that the previous could could've just been simplified to achieve same extensibility, but I guess perf. hash scales better and doesn't require colors to be sorted in advance (though that can be automated).
Testing
Tested by preexisting tests.