File tree Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Original file line number Diff line number Diff line change 1- // FIXME: Branch prediction hint. This is currently only available on nightly
2- // but it consistently improves performance by 10-15%.
3- #[ cfg( not( feature = "nightly" ) ) ]
4- pub ( crate ) use core:: convert:: { identity as likely, identity as unlikely} ;
1+ // FIXME: Replace with `core::hint::{likely, unlikely}` once they are stable.
52#[ cfg( feature = "nightly" ) ]
63pub ( crate ) use core:: intrinsics:: { likely, unlikely} ;
74
5+ #[ cfg( not( feature = "nightly" ) ) ]
6+ #[ inline( always) ]
7+ #[ cold]
8+ fn cold_path ( ) { }
9+
10+ #[ cfg( not( feature = "nightly" ) ) ]
11+ #[ inline( always) ]
12+ pub ( crate ) fn likely ( b : bool ) -> bool {
13+ if b {
14+ true
15+ } else {
16+ cold_path ( ) ;
17+ false
18+ }
19+ }
20+
21+ #[ cfg( not( feature = "nightly" ) ) ]
22+ #[ inline( always) ]
23+ pub ( crate ) fn unlikely ( b : bool ) -> bool {
24+ if b {
25+ cold_path ( ) ;
26+ true
27+ } else {
28+ false
29+ }
30+ }
31+
832// FIXME: use strict provenance functions once they are stable.
933// Implement it with a transmute for now.
1034#[ inline( always) ]
You can’t perform that action at this time.
0 commit comments