-
Notifications
You must be signed in to change notification settings - Fork 7
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
Proposal: Use integers for FontStyle #6
Comments
I think bitwise operations will decrease output's performance. |
@data-man That may be right for checking a specific field of the FontStyle, i.e. checking whether But for other purposes, this has increased performance:
All operations are turned into O(1) operations instead of O(n) where n is the number of fields. |
And for convenience, some helpers will be needed: isBold/setBold, etc. |
@data-man Yes, that would aid the usability of I'll leave this proposal open until some benchmarks have been integrated into the library. From then on, we can test the performance of checking attributes/setting attributes/checking equality/subset of attributes/etc. And from these results, we can then proceed to select the appropriate representation of |
@joachimschmidt557 |
@data-man If you want, feel free to implement that. |
pub const FontStyle = packed struct {
...
const Self = @This();
...
pub fn asUInt(self: Self) u11 {
return @bitCast(u11, self);
}
... ? |
@data-man Yup, don't know why this hasn't occurred to me yet. This means we can get the best of both worlds. I guess we can close this issue now. |
Currently,
FontStyle
is represented as a (possibly packed after #5) struct of bools.I think using integer types and bitwise operations, we could achieve better and possibly faster functionality. Consider the following simplified example:
Combining font styles can be done with bitwise or; checking for a style can be done with bitwise and.
cc @data-man
The text was updated successfully, but these errors were encountered: