mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
Remove type size check, looks like its not needed
Add check if the type is float. Float byte comparison doesn't work because +0.0 and -0.0 are considered equal but their byte representations are not equal.
This commit is contained in:
parent
997451da03
commit
db51821a97
@ -897,7 +897,9 @@ fn boyerMooreHorspoolPreprocess(pattern: []const u8, table: *[256]usize) void {
|
||||
pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?usize {
|
||||
if (needle.len > haystack.len or needle.len == 0) return null;
|
||||
|
||||
if (!isValidAlign(T.bit_count) or haystack.len < 32 or needle.len <= 2)
|
||||
// byte comparison with float doesn't work because +0.0 and -0.0 and considered
|
||||
// equal but their byte representations are not equal.
|
||||
if (@typeInfo(T) == .Float or haystack.len < 32 or needle.len <= 2)
|
||||
return lastIndexOfLinear(T, haystack, needle);
|
||||
|
||||
const haystack_bytes = sliceAsBytes(haystack);
|
||||
@ -921,7 +923,9 @@ pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?us
|
||||
pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, needle: []const T) ?usize {
|
||||
if (needle.len > haystack.len or needle.len == 0) return null;
|
||||
|
||||
if (!isValidAlign(T.bit_count) or haystack.len < 32 or needle.len <= 2)
|
||||
// byte comparison with float doesn't work because +0.0 and -0.0 and considered
|
||||
// equal but their byte representations are not equal.
|
||||
if (@typeInfo(T) == .Float or haystack.len < 32 or needle.len <= 2)
|
||||
return indexOfPosLinear(T, haystack, start_index, needle);
|
||||
|
||||
const haystack_bytes = sliceAsBytes(haystack);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user