Comments (8)
@data-man Yes, that would aid the usability of FontStyle
if it would be represented as an integer. But those will be small functions which will be almost-surely inlined in a release build, so the overhead of an additional function call won't be there, only the overhead of the bitwise operation then.
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 FontStyle
from ansi-term.
@data-man If you want, feel free to implement that.
from ansi-term.
@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.
from ansi-term.
I think bitwise operations will decrease output's performance.
from ansi-term.
@data-man That may be right for checking a specific field of the FontStyle, i.e. checking whether font_style.bold == true
. When using integers, we have an additional overhead of one bitwise operation in addition to the comparison.
But for other purposes, this has increased performance:
- checking if multiple fields are set
- checking for equality (includes checking
isDefault
) - checking if a given font style has at least the attributes of another font style (no attributes were removed)
All operations are turned into O(1) operations instead of O(n) where n is the number of fields.
from ansi-term.
When using integers, we have an additional overhead of one bitwise operation in addition to the comparison.
And for convenience, some helpers will be needed: isBold/setBold, etc.
from ansi-term.
@joachimschmidt557
I think helpers for RGB type are more important. Maybe in new module.
Rust's rgb24 as example.
from ansi-term.
pub const FontStyle = packed struct {
...
const Self = @This();
...
pub fn asUInt(self: Self) u11 {
return @bitCast(u11, self);
}
...
?
from ansi-term.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansi-term.