File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -83,8 +83,11 @@ const fn memchr_aligned(x: u8, text: &[u8]) -> Option<usize> {
83
83
let mut offset = ptr. align_offset ( USIZE_BYTES ) ;
84
84
85
85
if offset > 0 {
86
- offset = cmp:: min ( offset, len) ;
87
- if let Some ( index) = memchr_naive ( x, & text[ ..offset] ) {
86
+ // FIXME(const-hack, fee1-dead): replace with min
87
+ offset = if offset < len { offset } else { len } ;
88
+ // FIXME(const-hack, fee1-dead): replace with range slicing
89
+ let slice = unsafe { super :: from_raw_parts ( text. as_ptr ( ) , offset) } ;
90
+ if let Some ( index) = memchr_naive ( x, slice) {
88
91
return Some ( index) ;
89
92
}
90
93
}
@@ -110,7 +113,9 @@ const fn memchr_aligned(x: u8, text: &[u8]) -> Option<usize> {
110
113
111
114
// Find the byte after the point the body loop stopped.
112
115
// FIXME(const-hack): Use `?` instead.
113
- if let Some ( i) = memchr_naive ( x, & text[ offset..] ) { Some ( offset + i) } else { None }
116
+ // FIXME(const-hack, fee1-dead): use range slicing
117
+ let slice = unsafe { super :: from_raw_parts ( text. as_ptr ( ) . add ( offset) , text. len ( ) - offset) } ;
118
+ if let Some ( i) = memchr_naive ( x, slice) { Some ( offset + i) } else { None }
114
119
}
115
120
116
121
/// Returns the last index matching the byte `x` in `text`.
You can’t perform that action at this time.
0 commit comments