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

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

Original Pull Request: https://github.com/microsoft/terminal/pull/13093

State: closed
Merged: Yes


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
**Original Pull Request:** https://github.com/microsoft/terminal/pull/13093 **State:** closed **Merged:** Yes --- 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` ✅
claunia added the pull-request label 2026-01-31 09:34:36 +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#29391