Repository navigation
Simplify MSYS check in is_terminal on Windows - #164261
Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| // Lambdas are used to allow the compiler to short-circuit the is_pty check. | ||
| let is_msys = || name.starts_with(utf16!("msys-")) || name.starts_with(utf16!("cygwin-")); | ||
| let is_pty = || name.array_windows::<4>().any(|part| part == utf16!("-pty")); | ||
| is_msys() && is_pty() |
There was a problem hiding this comment.
You can find an assembly comparison here: https://godbolt.org/z/or4szY9Wb
FWIW, I have fuzzed this change locally and could not spot any regressions.
This comment has been minimized.
This comment has been minimized.
|
My hope is we can eventually remove this hack since msys and git bash are moving to the native pseudo console API by default. But it's probably still too early to do that. |
|
Thanks, I confirmed this does indeed improve codegen and doesn't appear to cause regressions (to the extent of my testing). r? ChrisDenton |
…uwer Rollup of 9 pull requests Successful merges: - #163743 (std: simplify the miri bypass of the stack overflow detection logic) - #164474 (core: implement `char::is_xid_{start|continue}`) - #164643 (Const-stabilize `{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque)::{len, is_empty}`) - #164739 (Use cfi_encoding instead of name in abi checking in miri) - #162927 (stabilize ptr_cast_slice) - #163372 (Restrict `PartialEq` and `PartialOrd` documentation to thin pointers) - #164261 (Simplify MSYS check in is_terminal on Windows) - #164698 (Remove FCP from libs tracking checklist) - #164810 (Don't prioritize issues that require internal features)
Rollup merge of #164261 - lhecker:is-terminal-simplification, r=ChrisDenton Simplify MSYS check in is_terminal on Windows The diff is a mess but it's actually a trivial change: * Avoid `MAX_PATH` array init on stack using `MaybeUninit` * Remove `from_utf16_lossy` and convert all checks to `utf16!()` To round it off this PR changes `is_msys && is_pty` to lambdas, which lets LLVM short-circuit the `is_pty` check! It gets fully inlined. This results in an almost 5x binary size reduction and 5-10x CPU cost reduction (although it was only 100ns to begin with).
…uwer Rollup of 9 pull requests Successful merges: - rust-lang/rust#163743 (std: simplify the miri bypass of the stack overflow detection logic) - rust-lang/rust#164474 (core: implement `char::is_xid_{start|continue}`) - rust-lang/rust#164643 (Const-stabilize `{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque)::{len, is_empty}`) - rust-lang/rust#164739 (Use cfi_encoding instead of name in abi checking in miri) - rust-lang/rust#162927 (stabilize ptr_cast_slice) - rust-lang/rust#163372 (Restrict `PartialEq` and `PartialOrd` documentation to thin pointers) - rust-lang/rust#164261 (Simplify MSYS check in is_terminal on Windows) - rust-lang/rust#164698 (Remove FCP from libs tracking checklist) - rust-lang/rust#164810 (Don't prioritize issues that require internal features)
The diff is a mess but it's actually a trivial change:
MAX_PATHarray init on stack usingMaybeUninitfrom_utf16_lossyand convert all checks toutf16!()To round it off this PR changes
is_msys && is_ptyto lambdas, whichlets LLVM short-circuit the
is_ptycheck! It gets fully inlined.This results in an almost 5x binary size reduction and 5-10x
CPU cost reduction (although it was only 100ns to begin with).