| author | |
| committer | |
| log | 30698b03c0420e897244441a60a8a8d1a4ade9f4 |
| tree | 3c64315414e67080f7b45957cba7799e5e6ad56e |
| parent | 71f23402bcbb8554d5663ac5aa870abd69fda10f |
| parent | 75c717bd064ac8cd21ee32b57b73b2a8673f1e41 |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/3525311 files changed, 20 insertions(+), 96 deletions(-)
lib/compiler/aro/aro/Preprocessor.zig+2-2| ... | ... | @@ -45,11 +45,11 @@ const IfContext = struct { |
| 45 | 45 | level: u8, |
| 46 | 46 | |
| 47 | 47 | fn get(self: *const IfContext) Nesting { |
| 48 | return @enumFromInt(std.mem.readPackedIntNative(Backing, &self.kind, @as(usize, self.level) * 2)); | |
| 48 | return @enumFromInt(std.mem.readPackedInt(Backing, &self.kind, @as(usize, self.level) * 2, .native)); | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | fn set(self: *IfContext, context: Nesting) void { |
| 52 | std.mem.writePackedIntNative(Backing, &self.kind, @as(usize, self.level) * 2, @intFromEnum(context)); | |
| 52 | std.mem.writePackedInt(Backing, &self.kind, @as(usize, self.level) * 2, @intFromEnum(context), .native); | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | fn increment(self: *IfContext) bool { |
lib/compiler/aro/backend/Ir/x86/Renderer.zig+3-3| ... | ... | @@ -21,17 +21,17 @@ const RegisterManager = zig.RegisterManager(Renderer, Register, Ir.Ref, abi.allo |
| 21 | 21 | const RegisterBitSet = RegisterManager.RegisterBitSet; |
| 22 | 22 | const RegisterClass = struct { |
| 23 | 23 | const gp: RegisterBitSet = blk: { |
| 24 | var set = RegisterBitSet.initEmpty(); | |
| 24 | var set: RegisterBitSet = .empty; | |
| 25 | 25 | for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .general_purpose) set.set(index); |
| 26 | 26 | break :blk set; |
| 27 | 27 | }; |
| 28 | 28 | const x87: RegisterBitSet = blk: { |
| 29 | var set = RegisterBitSet.initEmpty(); | |
| 29 | var set: RegisterBitSet = .empty; | |
| 30 | 30 | for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .x87) set.set(index); |
| 31 | 31 | break :blk set; |
| 32 | 32 | }; |
| 33 | 33 | const sse: RegisterBitSet = blk: { |
| 34 | var set = RegisterBitSet.initEmpty(); | |
| 34 | var set: RegisterBitSet = .empty; | |
| 35 | 35 | for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .sse) set.set(index); |
| 36 | 36 | break :blk set; |
| 37 | 37 | }; |
lib/compiler_rt/float_from_int.zig+1-1| ... | ... | @@ -97,7 +97,7 @@ pub inline fn floatFromBigInt(comptime T: type, comptime signedness: std.builtin |
| 97 | 97 | if (limb(x, limb_index) != 0) break true; |
| 98 | 98 | } else limb(x, exponent_limb) & ((@as(u32, 1) << @truncate(exponent)) - 1) != 0; |
| 99 | 99 | return math.ldexp(@as(T, @floatFromInt( |
| 100 | std.mem.readPackedIntNative(I, std.mem.sliceAsBytes(x), exponent) | @intFromBool(sticky), | |
| 100 | std.mem.readPackedInt(I, std.mem.sliceAsBytes(x), exponent, .native) | @intFromBool(sticky), | |
| 101 | 101 | )), @intCast(exponent)); |
| 102 | 102 | } |
| 103 | 103 |
lib/compiler_rt/int_from_float.zig+1-1| ... | ... | @@ -141,7 +141,7 @@ pub inline fn bigIntFromFloat(comptime signedness: std.builtin.Signedness, resul |
| 141 | 141 | }, |
| 142 | 142 | .unsigned => @memset(result, 0), |
| 143 | 143 | } |
| 144 | std.mem.writePackedIntNative(I, std.mem.sliceAsBytes(result), exponent, int); | |
| 144 | std.mem.writePackedInt(I, std.mem.sliceAsBytes(result), exponent, int, .native); | |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | test { |
lib/std/Io/Threaded.zig+1-1| ... | ... | @@ -14401,7 +14401,7 @@ pub fn setTimestampToPosix(set_ts: File.SetTimestamp) posix.timespec { |
| 14401 | 14401 | } |
| 14402 | 14402 | |
| 14403 | 14403 | pub fn pathToPosix(file_path: []const u8, buffer: *[posix.PATH_MAX]u8) Dir.PathNameError![:0]u8 { |
| 14404 | if (std.mem.containsAtLeastScalar2(u8, file_path, 0, 1)) return error.BadPathName; | |
| 14404 | if (std.mem.containsAtLeastScalar(u8, file_path, 0, 1)) return error.BadPathName; | |
| 14405 | 14405 | // >= rather than > to make room for the null byte |
| 14406 | 14406 | if (file_path.len >= buffer.len) return error.NameTooLong; |
| 14407 | 14407 | @memcpy(buffer[0..file_path.len], file_path); |
lib/std/ascii.zig-9| ... | ... | @@ -378,17 +378,11 @@ test endsWithIgnoreCase { |
| 378 | 378 | try std.testing.expect(!endsWithIgnoreCase("BoB", "Bo")); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | /// Deprecated in favor of `findIgnoreCase`. | |
| 382 | pub const indexOfIgnoreCase = findIgnoreCase; | |
| 383 | ||
| 384 | 381 | /// Finds `needle` in `haystack`, ignoring case, starting at index 0. |
| 385 | 382 | pub fn findIgnoreCase(haystack: []const u8, needle: []const u8) ?usize { |
| 386 | 383 | return findIgnoreCasePos(haystack, 0, needle); |
| 387 | 384 | } |
| 388 | 385 | |
| 389 | /// Deprecated in favor of `findIgnoreCasePos`. | |
| 390 | pub const indexOfIgnoreCasePos = findIgnoreCasePos; | |
| 391 | ||
| 392 | 386 | /// Finds `needle` in `haystack`, ignoring case, starting at `start_index`. |
| 393 | 387 | /// Uses Boyer-Moore-Horspool algorithm on large inputs; `findIgnoreCasePosLinear` on small inputs. |
| 394 | 388 | pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize { |
| ... | ... | @@ -410,9 +404,6 @@ pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []con |
| 410 | 404 | return null; |
| 411 | 405 | } |
| 412 | 406 | |
| 413 | /// Deprecated in favor of `findIgnoreCaseLinear`. | |
| 414 | pub const indexOfIgnoreCasePosLinear = findIgnoreCasePosLinear; | |
| 415 | ||
| 416 | 407 | /// Consider using `findIgnoreCasePos` instead of this, which will automatically use a |
| 417 | 408 | /// more sophisticated algorithm on larger inputs. |
| 418 | 409 | pub fn findIgnoreCasePosLinear(haystack: []const u8, start_index: usize, needle: []const u8) ?usize { |
lib/std/bit_set.zig-24| ... | ... | @@ -73,18 +73,6 @@ pub fn Integer(comptime size: u16) type { |
| 73 | 73 | /// The bit mask, as a single integer |
| 74 | 74 | mask: MaskInt, |
| 75 | 75 | |
| 76 | /// Deprecated: use `.empty`. | |
| 77 | /// Creates a bit set with no elements present. | |
| 78 | pub fn initEmpty() Self { | |
| 79 | return .{ .mask = 0 }; | |
| 80 | } | |
| 81 | ||
| 82 | /// Deprecated: use `.full`. | |
| 83 | /// Creates a bit set with all elements present. | |
| 84 | pub fn initFull() Self { | |
| 85 | return .{ .mask = ~@as(MaskInt, 0) }; | |
| 86 | } | |
| 87 | ||
| 88 | 76 | /// A bit set with no elements present. |
| 89 | 77 | pub const empty: Self = .{ .mask = 0 }; |
| 90 | 78 | |
| ... | ... | @@ -403,18 +391,6 @@ pub fn Array(comptime MaskIntType: type, comptime size: usize) type { |
| 403 | 391 | /// Padding bits at the end are undefined. |
| 404 | 392 | masks: [num_masks]MaskInt, |
| 405 | 393 | |
| 406 | /// Deprecated: use `.empty`. | |
| 407 | /// Creates a bit set with no elements present. | |
| 408 | pub fn initEmpty() Self { | |
| 409 | return .empty; | |
| 410 | } | |
| 411 | ||
| 412 | /// Deprecated: use `.full`. | |
| 413 | /// Creates a bit set with all elements present. | |
| 414 | pub fn initFull() Self { | |
| 415 | return .full; | |
| 416 | } | |
| 417 | ||
| 418 | 394 | /// A bit set with no elements present. |
| 419 | 395 | pub const empty: Self = .{ .masks = @splat(0) }; |
| 420 | 396 |
lib/std/enums.zig-12| ... | ... | @@ -284,18 +284,6 @@ pub fn EnumSet(comptime E: type) type { |
| 284 | 284 | /// A set containing all possible keys. |
| 285 | 285 | pub const full: Self = .{ .bits = .full }; |
| 286 | 286 | |
| 287 | /// Deprecated: use `.empty`. | |
| 288 | /// Returns a set containing no keys. | |
| 289 | pub fn initEmpty() Self { | |
| 290 | return .empty; | |
| 291 | } | |
| 292 | ||
| 293 | /// Deprecated: use `.full`. | |
| 294 | /// Returns a set containing all possible keys. | |
| 295 | pub fn initFull() Self { | |
| 296 | return .full; | |
| 297 | } | |
| 298 | ||
| 299 | 287 | /// Returns a set containing multiple keys. |
| 300 | 288 | pub fn initMany(keys: []const Key) Self { |
| 301 | 289 | var set: Self = .empty; |
lib/std/mem.zig+9-38| ... | ... | @@ -1691,7 +1691,7 @@ test countScalar { |
| 1691 | 1691 | // |
| 1692 | 1692 | /// See also: `containsAtLeastScalar` |
| 1693 | 1693 | pub fn containsAtLeast(comptime T: type, haystack: []const T, expected_count: usize, needle: []const T) bool { |
| 1694 | if (needle.len == 1) return containsAtLeastScalar(T, haystack, expected_count, needle[0]); | |
| 1694 | if (needle.len == 1) return containsAtLeastScalar(T, haystack, needle[0], expected_count); | |
| 1695 | 1695 | assert(needle.len > 0); |
| 1696 | 1696 | if (expected_count == 0) return true; |
| 1697 | 1697 | |
| ... | ... | @@ -1722,17 +1722,12 @@ test containsAtLeast { |
| 1722 | 1722 | try testing.expect(!containsAtLeast(u8, " radar radar ", 3, "radar")); |
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | /// Deprecated in favor of `containsAtLeastScalar2`. | |
| 1726 | pub fn containsAtLeastScalar(comptime T: type, list: []const T, minimum: usize, element: T) bool { | |
| 1727 | return containsAtLeastScalar2(T, list, element, minimum); | |
| 1728 | } | |
| 1729 | ||
| 1730 | 1725 | /// Returns true if `element` appears at least `minimum` number of times in `list`. |
| 1731 | 1726 | // |
| 1732 | 1727 | /// Related: |
| 1733 | 1728 | /// * `containsAtLeast` |
| 1734 | 1729 | /// * `countScalar` |
| 1735 | pub fn containsAtLeastScalar2(comptime T: type, list: []const T, element: T, minimum: usize) bool { | |
| 1730 | pub fn containsAtLeastScalar(comptime T: type, list: []const T, element: T, minimum: usize) bool { | |
| 1736 | 1731 | const n = list.len; |
| 1737 | 1732 | var i: usize = 0; |
| 1738 | 1733 | var found: usize = 0; |
| ... | ... | @@ -1760,14 +1755,14 @@ pub fn containsAtLeastScalar2(comptime T: type, list: []const T, element: T, min |
| 1760 | 1755 | return false; |
| 1761 | 1756 | } |
| 1762 | 1757 | |
| 1763 | test containsAtLeastScalar2 { | |
| 1764 | try testing.expect(containsAtLeastScalar2(u8, "aa", 'a', 0)); | |
| 1765 | try testing.expect(containsAtLeastScalar2(u8, "aa", 'a', 1)); | |
| 1766 | try testing.expect(containsAtLeastScalar2(u8, "aa", 'a', 2)); | |
| 1767 | try testing.expect(!containsAtLeastScalar2(u8, "aa", 'a', 3)); | |
| 1758 | test containsAtLeastScalar { | |
| 1759 | try testing.expect(containsAtLeastScalar(u8, "aa", 'a', 0)); | |
| 1760 | try testing.expect(containsAtLeastScalar(u8, "aa", 'a', 1)); | |
| 1761 | try testing.expect(containsAtLeastScalar(u8, "aa", 'a', 2)); | |
| 1762 | try testing.expect(!containsAtLeastScalar(u8, "aa", 'a', 3)); | |
| 1768 | 1763 | |
| 1769 | try testing.expect(containsAtLeastScalar2(u8, "adadda", 'd', 3)); | |
| 1770 | try testing.expect(!containsAtLeastScalar2(u8, "adadda", 'd', 4)); | |
| 1764 | try testing.expect(containsAtLeastScalar(u8, "adadda", 'd', 3)); | |
| 1765 | try testing.expect(!containsAtLeastScalar(u8, "adadda", 'd', 4)); | |
| 1771 | 1766 | } |
| 1772 | 1767 | |
| 1773 | 1768 | /// Reads an integer from memory with size equal to bytes.len. |
| ... | ... | @@ -1973,18 +1968,6 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T { |
| 1973 | 1968 | } else return @as(T, @bitCast(val)); |
| 1974 | 1969 | } |
| 1975 | 1970 | |
| 1976 | /// Deprecated: use readPackedInt(T, bytes, bit_offset, value, .native) | |
| 1977 | pub const readPackedIntNative = switch (native_endian) { | |
| 1978 | .little => readPackedIntLittle, | |
| 1979 | .big => readPackedIntBig, | |
| 1980 | }; | |
| 1981 | ||
| 1982 | /// Deprecated: use readPackedInt(T, bytes, bit_offset, value, .foreign) | |
| 1983 | pub const readPackedIntForeign = switch (native_endian) { | |
| 1984 | .little => readPackedIntBig, | |
| 1985 | .big => readPackedIntLittle, | |
| 1986 | }; | |
| 1987 | ||
| 1988 | 1971 | /// Loads an integer from packed memory. |
| 1989 | 1972 | /// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits. |
| 1990 | 1973 | pub fn readPackedInt(comptime T: type, bytes: []const u8, bit_offset: usize, endian: Endian) T { |
| ... | ... | @@ -2128,18 +2111,6 @@ fn writePackedIntBig(comptime T: type, bytes: []u8, bit_offset: usize, value: T) |
| 2128 | 2111 | writeInt(StoreInt, write_bytes[(byte_count - store_size)..][0..store_size], write_value, .big); |
| 2129 | 2112 | } |
| 2130 | 2113 | |
| 2131 | /// Deprecated: use writePackedInt(T, bytes, bit_offset, value, .native) | |
| 2132 | pub const writePackedIntNative = switch (native_endian) { | |
| 2133 | .little => writePackedIntLittle, | |
| 2134 | .big => writePackedIntBig, | |
| 2135 | }; | |
| 2136 | ||
| 2137 | /// Deprecated: use writePackedInt(T, bytes, bit_offset, value, .foreign) | |
| 2138 | pub const writePackedIntForeign = switch (native_endian) { | |
| 2139 | .little => writePackedIntBig, | |
| 2140 | .big => writePackedIntLittle, | |
| 2141 | }; | |
| 2142 | ||
| 2143 | 2114 | /// Stores an integer to packed memory. |
| 2144 | 2115 | /// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits. |
| 2145 | 2116 | pub fn writePackedInt(comptime T: type, bytes: []u8, bit_offset: usize, value: T, endian: Endian) void { |
src/Package/Fetch.zig+2-2| ... | ... | @@ -1151,10 +1151,10 @@ const FileType = enum { |
| 1151 | 1151 | |
| 1152 | 1152 | /// Parameter is a content-disposition header value. |
| 1153 | 1153 | fn fromContentDisposition(cd_header: []const u8) ?FileType { |
| 1154 | const attach_end = ascii.indexOfIgnoreCase(cd_header, "attachment;") orelse | |
| 1154 | const attach_end = ascii.findIgnoreCase(cd_header, "attachment;") orelse | |
| 1155 | 1155 | return null; |
| 1156 | 1156 | |
| 1157 | var value_start = ascii.indexOfIgnoreCasePos(cd_header, attach_end + 1, "filename") orelse | |
| 1157 | var value_start = ascii.findIgnoreCasePos(cd_header, attach_end + 1, "filename") orelse | |
| 1158 | 1158 | return null; |
| 1159 | 1159 | value_start += "filename".len; |
| 1160 | 1160 | if (cd_header[value_start] == '*') { |
src/codegen/x86_64/CodeGen.zig+1-3| ... | ... | @@ -187562,9 +187562,7 @@ const Temp = struct { |
| 187562 | 187562 | const max = std.math.maxInt(@typeInfo(Index).@"enum".tag_type); |
| 187563 | 187563 | const Set = std.bit_set.Static(max); |
| 187564 | 187564 | const SafetySet = if (std.debug.runtime_safety) Set else struct { |
| 187565 | inline fn initEmpty() @This() { | |
| 187566 | return .{}; | |
| 187567 | } | |
| 187565 | pub const empty: @This() = .{}; | |
| 187568 | 187566 | |
| 187569 | 187567 | inline fn isSet(_: @This(), index: usize) bool { |
| 187570 | 187568 | assert(index < max); |