[PR #13093] [MERGED] Various improvements for til::hash/point/size/rect #29386

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13093
Author: @lhecker
Created: 5/13/2022
Status: Merged
Merged: 5/17/2022
Merged by: @undefined

Base: mainHead: dev/lhecker/4015-split2


📝 Commits (4)

📊 Changes

12 files changed (+264 additions, -466 deletions)

View changed files

📝 src/inc/til/at.h (+14 -14)
📝 src/inc/til/bit.h (+10 -0)
📝 src/inc/til/hash.h (+7 -1)
📝 src/inc/til/point.h (+40 -24)
📝 src/inc/til/rect.h (+114 -200)
📝 src/inc/til/size.h (+38 -44)
📝 src/renderer/dx/DxRenderer.cpp (+4 -1)
📝 src/terminal/adapter/FontBuffer.cpp (+1 -1)
📝 src/terminal/adapter/FontBuffer.hpp (+1 -1)
📝 src/til/ut_til/PointTests.cpp (+7 -0)
📝 src/til/ut_til/RectangleTests.cpp (+17 -156)
📝 src/til/ut_til/SizeTests.cpp (+11 -24)

📄 Description

This commit includes various minor improvements to til::hash/point/size/rect
which accumulated while working on #4015.

  • Allow xvalue containers and non-size_t indices in til::at.
  • til::as_unsigned can be used to reinterpret a potentially signed integer
    as a unsigned one. This can potentially enable some optimizations as no sign
    extension is needed anymore. til::hash can make use of this to drop about
    20% of the hashing of signed integers <= 32 bit. On x86 this translates to
    a mov (virtually no latency) or no instructions at all, instead of
    requiring a movsx (some latency) for sign extension.
  • til::point operators that prefer mutability.
    This is a opinionated change, but it follows the STL style beter and
    generates less assembly.
  • Simpler rect scale_up/down and size divide_ceil.
    scale_up will not depend on the operator header anymore.
    scale_down / divide_ceil can be implemented without checked numerics,
    so I did. It also follows the related GdiEngine code better now, which
    makes me confident that we can replace GdiEngine's code with this.
  • Removal of rect-size-shift operators.
    They were only used in DxEngine and confusing as they weren't commutative.
    Adding and then subtracting a size from a rect (and vice versa) didn't do
    what you'd intuitively think it'd do. The code was replaced with addition
    and clamps in DxEngine.
  • Various unsafe as_ casts for point/size/rect.
    This will aid the migration in #4015.

Validation Steps Performed

  • Vertical scrolling works in DxEngine

🔄 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/13093 **Author:** [@lhecker](https://github.com/lhecker) **Created:** 5/13/2022 **Status:** ✅ Merged **Merged:** 5/17/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/lhecker/4015-split2` --- ### 📝 Commits (4) - [`804559b`](https://github.com/microsoft/terminal/commit/804559b8d8b9aa1b1e16ff0d500d8994455db3bd) Various improvements for til::hash/point/size/rect - [`a5d110a`](https://github.com/microsoft/terminal/commit/a5d110ad1699c74cfe24f224ffdefafcfa4c7ef1) Fix AuditMode checks - [`256ab9d`](https://github.com/microsoft/terminal/commit/256ab9d13dc2b336094ec9b0d71175951d22bf6a) Fixed wording - [`d23506b`](https://github.com/microsoft/terminal/commit/d23506be480ab5bf3ddab311865f2cdf72df3f92) Address feedback ### 📊 Changes **12 files changed** (+264 additions, -466 deletions) <details> <summary>View changed files</summary> 📝 `src/inc/til/at.h` (+14 -14) 📝 `src/inc/til/bit.h` (+10 -0) 📝 `src/inc/til/hash.h` (+7 -1) 📝 `src/inc/til/point.h` (+40 -24) 📝 `src/inc/til/rect.h` (+114 -200) 📝 `src/inc/til/size.h` (+38 -44) 📝 `src/renderer/dx/DxRenderer.cpp` (+4 -1) 📝 `src/terminal/adapter/FontBuffer.cpp` (+1 -1) 📝 `src/terminal/adapter/FontBuffer.hpp` (+1 -1) 📝 `src/til/ut_til/PointTests.cpp` (+7 -0) 📝 `src/til/ut_til/RectangleTests.cpp` (+17 -156) 📝 `src/til/ut_til/SizeTests.cpp` (+11 -24) </details> ### 📄 Description This commit includes various minor improvements to til::hash/point/size/rect which accumulated while working on #4015. * Allow xvalue containers and non-`size_t` indices in `til::at`. * `til::as_unsigned` can be used to reinterpret a potentially signed integer as a unsigned one. This can potentially enable some optimizations as no sign extension is needed anymore. `til::hash` can make use of this to drop about 20% of the hashing of signed integers <= 32 bit. On x86 this translates to a `mov` (virtually no latency) or no instructions at all, instead of requiring a `movsx` (some latency) for sign extension. * `til::point` operators that prefer mutability. This is a opinionated change, but it follows the STL style beter and generates less assembly. * Simpler `rect` scale_up/down and `size` divide_ceil. `scale_up` will not depend on the operator header anymore. `scale_down` / `divide_ceil` can be implemented without checked numerics, so I did. It also follows the related GdiEngine code better now, which makes me confident that we can replace GdiEngine's code with this. * Removal of rect-size-shift operators. They were only used in DxEngine and confusing as they weren't commutative. Adding and then subtracting a size from a rect (and vice versa) didn't do what you'd intuitively think it'd do. The code was replaced with addition and clamps in DxEngine. * Various unsafe `as_` casts for point/size/rect. This will aid the migration in #4015. ## Validation Steps Performed * Vertical scrolling works in `DxEngine` ✅ --- <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:34:35 +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#29386