[PR #11902] Prepare til wrappers for migrating off of SMALL_RECT #28803

Closed
opened 2026-01-31 09:30:51 +00:00 by claunia · 0 comments
Owner

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

State: closed
Merged: Yes


This commit makes the following changes to til::point/size/rectangle
for the following reasons:

  • Rename rectangle into rect
    This will make the naming consistent with a later small_rect struct
    as well as the existing Win32 POINT/SIZE/RECT structs.
  • Standardizes til wrappers on int32_t instead of ptrdiff_t
    Provides a consistent behavior between x86 and x64, preventing accidental
    errors on x86, as it's less rigorously tested than x64. Additionally it
    improves interop with MIDL3 which only supports fixed width integer types.
  • Standardizes til wrappers on throwing gsl::narrow_error
    Makes the behavior of our code more consistent.
  • Makes all eligible functions constexpr
    Because why not.
  • Removes implicit constructors and conversion operators
    This is a complex and controversial topic. My reasons are: You can't Ctrl+F
    for an implicit conversion. This breaks most non-IDE engines, like the one on
    GitHub or those we have internally at MS. This is important for me as these
    implicit conversion operators aren't cost free. Narrowing integers itself,
    as well as the boundary checks that need to be done have a certain,
    fixed overhead each time. Additionally the lack of noexcept prevents
    many advanced compiler optimizations. Removing their use entirely
    drops conhost's code segment size by around ~6.5%.

References

Preliminary work for #4015.

PR Checklist

  • I work here
  • Tests added/passed

Validation Steps Performed

I'm mostly relying on our unit tests here. Both OpenConsole and WT appear to work fine.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/11902 **State:** closed **Merged:** Yes --- This commit makes the following changes to `til::point/size/rectangle` for the following reasons: * Rename `rectangle` into `rect` This will make the naming consistent with a later `small_rect` struct as well as the existing Win32 POINT/SIZE/RECT structs. * Standardizes til wrappers on `int32_t` instead of `ptrdiff_t` Provides a consistent behavior between x86 and x64, preventing accidental errors on x86, as it's less rigorously tested than x64. Additionally it improves interop with MIDL3 which only supports fixed width integer types. * Standardizes til wrappers on throwing `gsl::narrow_error` Makes the behavior of our code more consistent. * Makes all eligible functions `constexpr` Because why not. * Removes implicit constructors and conversion operators This is a complex and controversial topic. My reasons are: You can't Ctrl+F for an implicit conversion. This breaks most non-IDE engines, like the one on GitHub or those we have internally at MS. This is important for me as these implicit conversion operators aren't cost free. Narrowing integers itself, as well as the boundary checks that need to be done have a certain, fixed overhead each time. Additionally the lack of noexcept prevents many advanced compiler optimizations. Removing their use entirely drops conhost's code segment size by around ~6.5%. ## References Preliminary work for #4015. ## PR Checklist * [x] I work here * [x] Tests added/passed ## Validation Steps Performed I'm mostly relying on our unit tests here. Both OpenConsole and WT appear to work fine.
claunia added the pull-request label 2026-01-31 09:30:51 +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#28803