-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Merge the legacy and extended attributes #14036
Conversation
@@ -7,7 +7,7 @@ | |||
|
|||
// Keeping TextColor compact helps us keeping TextAttribute compact, | |||
// which in turn ensures that our buffer memory usage is low. | |||
static_assert(sizeof(TextAttribute) == 14); | |||
static_assert(sizeof(TextAttribute) == 12); |
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.
A memory savings of 2 megabytes, assuming that every column in every row in the default conhost buffer had 120 different attributes. 😁
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.
I'm 100% here for this. Thank you so much!
Hello @lhecker! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
This PR attempts to simplify the
TextAttribute
class by merging thetwo fields that were previously storing the "legacy" attributes and the
"extended" attributes separately.
When the
TextAttribute
class is initialized with a legacy value, wewere masking off the
META_ATTRS
bits to store in the_wAttrLegacy
field, and then additionally clearing the
COMMON_LVB_SBCSDBCS
bits,so there were only 5 bits that were actually used in the end. We also
had an additional
_extendedAttrs
field holding other VT attributes,which only used 8 of its available 16 bits.
In this PR I've now merged the the two sets of attributes into one enum,
so they all fit in a single 16-bit value. The legacy attributes retain
the same bit positions they originally had, so we can mask them off from
an incoming legacy value as we did before. I've just simplified the
process somewhat by creating a
USED_META_ATTRS
mask that covers theexact subset of meta attributes that we care about.
The new enum that holds the combined attributes has now been named
CharacterAttributes
rather thanExtendedAttributes
, since that seemsto be the term typically used in VT documentation. This covers both
rendition/visual attributes and logical attributes (not yet used, but we
will need them at some point to support selective erase operations).
While making these changes I also noticed the
IsLeadingByte
andIsTrailingByte
methods weren't actually used anywhere, and weren'tcorrectly implemented anyway, so I've removed those now.
Validation Steps Performed
I've manually run a number of attribute test scripts which cover both
legacy and VT operations, and everything still appears to be working
correctly.
Closes #14031