[PR #10566] [MERGED] Use memcmp for TextAttribute & TextColor comparison #28108

Open
opened 2026-01-31 09:26:24 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10566
Author: @skyline75489
Created: 7/6/2021
Status: ✅ Merged
Merged: 5/5/2022
Merged by: @undefined

Base: main ← Head: chesterliu/dev/text-colorrrr


📝 Commits (5)

  • e1c5726 Use memcmp for TextAttribute & TextColor comparison
  • ae4382e Missed one
  • e84eeae Nope, doesn't work
  • 149e967 Merge branch 'main' into chesterliu/dev/text-colorrrr
  • 5423de5 Merge branch 'main' into chesterliu/dev/text-colorrrr

📊 Changes

5 files changed (+29 additions, -37 deletions)

View changed files

📝 src/buffer/out/TextAttribute.cpp (+2 -0)
📝 src/buffer/out/TextAttribute.hpp (+10 -21)
📝 src/buffer/out/TextColor.cpp (+7 -0)
📝 src/buffer/out/TextColor.h (+9 -15)
📝 src/inc/conattrs.hpp (+1 -1)

📄 Description

TextAttribute and TextColor are commonly used structures in hot paths.
This commit replaces more complex comparisons where each field is compared
independently with a single call to memcmp. This compiles down to just
a few instructions. This reduces code and binary size and improves
performance for paths were TextAttributes need to be compared.

PR Checklist

  • Supports What about 'over all windows' as Task Manager? (#10563)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated.
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Validation Steps Performed

  • termbench still works ✔️

Co-authored-by: Leonard Hecker lhecker@microsoft.com


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/10566 **Author:** [@skyline75489](https://github.com/skyline75489) **Created:** 7/6/2021 **Status:** ✅ Merged **Merged:** 5/5/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `chesterliu/dev/text-colorrrr` --- ### 📝 Commits (5) - [`e1c5726`](https://github.com/microsoft/terminal/commit/e1c57265d95c7699d4c03d70482fce5794fda0f6) Use memcmp for TextAttribute & TextColor comparison - [`ae4382e`](https://github.com/microsoft/terminal/commit/ae4382e43d1368f0a26e0c3e8e1816c5e8288630) Missed one - [`e84eeae`](https://github.com/microsoft/terminal/commit/e84eeae396529e53d7acbc7148d77c2472907fa1) Nope, doesn't work - [`149e967`](https://github.com/microsoft/terminal/commit/149e967692dd3281f2b2450b86a220987fcf81ae) Merge branch 'main' into chesterliu/dev/text-colorrrr - [`5423de5`](https://github.com/microsoft/terminal/commit/5423de51ff3477164fd69e0167ccb9cac09f5f61) Merge branch 'main' into chesterliu/dev/text-colorrrr ### 📊 Changes **5 files changed** (+29 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `src/buffer/out/TextAttribute.cpp` (+2 -0) 📝 `src/buffer/out/TextAttribute.hpp` (+10 -21) 📝 `src/buffer/out/TextColor.cpp` (+7 -0) 📝 `src/buffer/out/TextColor.h` (+9 -15) 📝 `src/inc/conattrs.hpp` (+1 -1) </details> ### 📄 Description `TextAttribute` and `TextColor` are commonly used structures in hot paths. This commit replaces more complex comparisons where each field is compared independently with a single call to `memcmp`. This compiles down to just a few instructions. This reduces code and binary size and improves performance for paths were `TextAttribute`s need to be compared. ## PR Checklist * [x] Supports #10563 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Validation Steps Performed * termbench still works ✔️ Co-authored-by: Leonard Hecker <lhecker@microsoft.com> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:26:24 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28108