| author | |
| committer | |
| log | d02d0b879c143e1495fc360845d6feec1ac293ed |
| tree | c0f3ccc7356862d19ab4d10f98e6c57404ed25e6 |
| parent | 845b6a8efe5ac71c9df02373fe3716814cb7b92d |
This PR merges the functionality of the `getLastOrNull` method into `getLast`, which improves consistency as its
based on methods like `front`, `back`, and `peek` in the `Deque` and `PriorityQueue` containers.
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/32008
Reviewed-by: Andrew Kelley <andrew@ziglang.org>11 files changed, 39 insertions(+), 60 deletions(-)
lib/compiler/build_runner.zig+1-1| ... | @@ -1397,7 +1397,7 @@ fn makeStep( | ... | @@ -1397,7 +1397,7 @@ fn makeStep( |
| 1397 | defer run.max_rss_mutex.unlock(io); | 1397 | defer run.max_rss_mutex.unlock(io); |
| 1398 | run.available_rss += s.max_rss; | 1398 | run.available_rss += s.max_rss; |
| 1399 | dispatch_set.ensureUnusedCapacity(gpa, run.memory_blocked_steps.items.len) catch @panic("OOM"); | 1399 | dispatch_set.ensureUnusedCapacity(gpa, run.memory_blocked_steps.items.len) catch @panic("OOM"); |
| 1400 | while (run.memory_blocked_steps.getLastOrNull()) |candidate| { | 1400 | while (run.memory_blocked_steps.getLast()) |candidate| { |
| 1401 | if (run.available_rss < candidate.max_rss) break; | 1401 | if (run.available_rss < candidate.max_rss) break; |
| 1402 | assert(run.memory_blocked_steps.pop() == candidate); | 1402 | assert(run.memory_blocked_steps.pop() == candidate); |
| 1403 | dispatch_set.appendAssumeCapacity(candidate); | 1403 | dispatch_set.appendAssumeCapacity(candidate); |
lib/compiler/translate-c/MacroTranslator.zig+1-1| ... | @@ -361,7 +361,7 @@ fn parseCNumLit(mt: *MacroTranslator) ParseError!ZigNode { | ... | @@ -361,7 +361,7 @@ fn parseCNumLit(mt: *MacroTranslator) ParseError!ZigNode { |
| 361 | return error.ParseError; | 361 | return error.ParseError; |
| 362 | }, | 362 | }, |
| 363 | }); | 363 | }); |
| 364 | if (bytes.getLast() == '.') { | 364 | if (bytes.getLast().? == '.') { |
| 365 | bytes.appendAssumeCapacity('0'); | 365 | bytes.appendAssumeCapacity('0'); |
| 366 | } else if (mem.findAny(u8, bytes.items, ".eEpP") == null) { | 366 | } else if (mem.findAny(u8, bytes.items, ".eEpP") == null) { |
| 367 | bytes.appendSliceAssumeCapacity(".0"); | 367 | bytes.appendSliceAssumeCapacity(".0"); |
lib/docs/wasm/markdown/Parser.zig+11-11| ... | @@ -209,7 +209,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { | ... | @@ -209,7 +209,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { |
| 209 | } else p.pending_blocks.items.len; | 209 | } else p.pending_blocks.items.len; |
| 210 | 210 | ||
| 211 | const in_code_block = p.pending_blocks.items.len > 0 and | 211 | const in_code_block = p.pending_blocks.items.len > 0 and |
| 212 | p.pending_blocks.getLast().tag == .code_block; | 212 | p.pending_blocks.getLast().?.tag == .code_block; |
| 213 | const code_block_end = in_code_block and | 213 | const code_block_end = in_code_block and |
| 214 | first_unmatched + 1 == p.pending_blocks.items.len; | 214 | first_unmatched + 1 == p.pending_blocks.items.len; |
| 215 | // New blocks cannot be started if we are actively inside a code block or | 215 | // New blocks cannot be started if we are actively inside a code block or |
| ... | @@ -225,7 +225,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { | ... | @@ -225,7 +225,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { |
| 225 | if (maybe_block_start == null and | 225 | if (maybe_block_start == null and |
| 226 | !isBlank(rest_line) and | 226 | !isBlank(rest_line) and |
| 227 | p.pending_blocks.items.len > 0 and | 227 | p.pending_blocks.items.len > 0 and |
| 228 | p.pending_blocks.getLast().tag == .paragraph) | 228 | p.pending_blocks.getLast().?.tag == .paragraph) |
| 229 | { | 229 | { |
| 230 | try p.addScratchStringLine(mem.trimStart(u8, rest_line, " \t")); | 230 | try p.addScratchStringLine(mem.trimStart(u8, rest_line, " \t")); |
| 231 | return; | 231 | return; |
| ... | @@ -236,7 +236,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { | ... | @@ -236,7 +236,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { |
| 236 | // paragraphs. | 236 | // paragraphs. |
| 237 | if (maybe_block_start != null and | 237 | if (maybe_block_start != null and |
| 238 | p.pending_blocks.items.len > 0 and | 238 | p.pending_blocks.items.len > 0 and |
| 239 | p.pending_blocks.getLast().tag == .paragraph) | 239 | p.pending_blocks.getLast().?.tag == .paragraph) |
| 240 | { | 240 | { |
| 241 | try p.closeLastBlock(); | 241 | try p.closeLastBlock(); |
| 242 | } | 242 | } |
| ... | @@ -259,7 +259,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { | ... | @@ -259,7 +259,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { |
| 259 | // Do not append the end of a code block (```) as textual content. | 259 | // Do not append the end of a code block (```) as textual content. |
| 260 | if (code_block_end) return; | 260 | if (code_block_end) return; |
| 261 | 261 | ||
| 262 | const can_accept = if (p.pending_blocks.getLastOrNull()) |last_pending_block| | 262 | const can_accept = if (p.pending_blocks.getLast()) |last_pending_block| |
| 263 | last_pending_block.canAccept() | 263 | last_pending_block.canAccept() |
| 264 | else | 264 | else |
| 265 | .blocks; | 265 | .blocks; |
| ... | @@ -273,7 +273,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { | ... | @@ -273,7 +273,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void { |
| 273 | // loose, since we might just be looking at a blank line after the | 273 | // loose, since we might just be looking at a blank line after the |
| 274 | // end of the last item in the list. The final determination will be | 274 | // end of the last item in the list. The final determination will be |
| 275 | // made when appending the next child of the list or list item. | 275 | // made when appending the next child of the list or list item. |
| 276 | const maybe_containing_list_index = if (p.pending_blocks.items.len > 0 and p.pending_blocks.getLast().tag == .list_item) | 276 | const maybe_containing_list_index = if (p.pending_blocks.items.len > 0 and p.pending_blocks.getLast().?.tag == .list_item) |
| 277 | p.pending_blocks.items.len - 2 | 277 | p.pending_blocks.items.len - 2 |
| 278 | else | 278 | else |
| 279 | null; | 279 | null; |
| ... | @@ -368,7 +368,7 @@ const BlockStart = struct { | ... | @@ -368,7 +368,7 @@ const BlockStart = struct { |
| 368 | }; | 368 | }; |
| 369 | 369 | ||
| 370 | fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { | 370 | fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { |
| 371 | if (p.pending_blocks.getLastOrNull()) |last_pending_block| { | 371 | if (p.pending_blocks.getLast()) |last_pending_block| { |
| 372 | // Close the last block if it is a list and the new block is not a list item | 372 | // Close the last block if it is a list and the new block is not a list item |
| 373 | // or not of the same marker type. | 373 | // or not of the same marker type. |
| 374 | const should_close_list = last_pending_block.tag == .list and | 374 | const should_close_list = last_pending_block.tag == .list and |
| ... | @@ -383,7 +383,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { | ... | @@ -383,7 +383,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { |
| 383 | } | 383 | } |
| 384 | } | 384 | } |
| 385 | 385 | ||
| 386 | if (p.pending_blocks.getLastOrNull()) |last_pending_block| { | 386 | if (p.pending_blocks.getLast()) |last_pending_block| { |
| 387 | // If the last block is a list or list item, check for tightness based | 387 | // If the last block is a list or list item, check for tightness based |
| 388 | // on the last line. | 388 | // on the last line. |
| 389 | const maybe_containing_list = switch (last_pending_block.tag) { | 389 | const maybe_containing_list = switch (last_pending_block.tag) { |
| ... | @@ -401,7 +401,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { | ... | @@ -401,7 +401,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { |
| 401 | // Start a new list if the new block is a list item and there is no | 401 | // Start a new list if the new block is a list item and there is no |
| 402 | // containing list yet. | 402 | // containing list yet. |
| 403 | if (block_start.tag == .list_item and | 403 | if (block_start.tag == .list_item and |
| 404 | (p.pending_blocks.items.len == 0 or p.pending_blocks.getLast().tag != .list)) | 404 | (p.pending_blocks.items.len == 0 or p.pending_blocks.getLast().?.tag != .list)) |
| 405 | { | 405 | { |
| 406 | try p.pending_blocks.append(p.allocator, .{ | 406 | try p.pending_blocks.append(p.allocator, .{ |
| 407 | .tag = .list, | 407 | .tag = .list, |
| ... | @@ -417,7 +417,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { | ... | @@ -417,7 +417,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { |
| 417 | 417 | ||
| 418 | if (block_start.tag == .table_row) { | 418 | if (block_start.tag == .table_row) { |
| 419 | // Likewise, table rows start a table implicitly. | 419 | // Likewise, table rows start a table implicitly. |
| 420 | if (p.pending_blocks.items.len == 0 or p.pending_blocks.getLast().tag != .table) { | 420 | if (p.pending_blocks.items.len == 0 or p.pending_blocks.getLast().?.tag != .table) { |
| 421 | try p.pending_blocks.append(p.allocator, .{ | 421 | try p.pending_blocks.append(p.allocator, .{ |
| 422 | .tag = .table, | 422 | .tag = .table, |
| 423 | .data = .{ .table = .{ | 423 | .data = .{ .table = .{ |
| ... | @@ -429,7 +429,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { | ... | @@ -429,7 +429,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { |
| 429 | }); | 429 | }); |
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | const current_row = p.scratch_extra.items.len - p.pending_blocks.getLast().extra_start; | 432 | const current_row = p.scratch_extra.items.len - p.pending_blocks.getLast().?.extra_start; |
| 433 | if (current_row <= 1) { | 433 | if (current_row <= 1) { |
| 434 | var buffer: [max_table_columns]Node.TableCellAlignment = undefined; | 434 | var buffer: [max_table_columns]Node.TableCellAlignment = undefined; |
| 435 | const table_row = &block_start.data.table_row; | 435 | const table_row = &block_start.data.table_row; |
| ... | @@ -441,7 +441,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { | ... | @@ -441,7 +441,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { |
| 441 | // We need to go back and mark the header row and its column | 441 | // We need to go back and mark the header row and its column |
| 442 | // alignments. | 442 | // alignments. |
| 443 | const datas = p.nodes.items(.data); | 443 | const datas = p.nodes.items(.data); |
| 444 | const header_data = datas[p.scratch_extra.getLast()]; | 444 | const header_data = datas[p.scratch_extra.getLast().?]; |
| 445 | for (p.extraChildren(header_data.container.children), 0..) |header_cell, i| { | 445 | for (p.extraChildren(header_data.container.children), 0..) |header_cell, i| { |
| 446 | const alignment = if (i < alignments.len) alignments[i] else .unset; | 446 | const alignment = if (i < alignments.len) alignments[i] else .unset; |
| 447 | const cell_data = &datas[@intFromEnum(header_cell)].table_cell; | 447 | const cell_data = &datas[@intFromEnum(header_cell)].table_cell; |
lib/std/array_list.zig+10-31| ... | @@ -544,16 +544,13 @@ pub fn AlignedManaged(comptime T: type, comptime alignment: ?mem.Alignment) type | ... | @@ -544,16 +544,13 @@ pub fn AlignedManaged(comptime T: type, comptime alignment: ?mem.Alignment) type |
| 544 | return self.allocatedSlice()[self.items.len..]; | 544 | return self.allocatedSlice()[self.items.len..]; |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | /// Returns the last element from the list. | 547 | /// Deprecated in favor of `getLast` |
| 548 | /// Asserts that the list is not empty. | 548 | pub const getLastOrNull = getLast; |
| 549 | pub fn getLast(self: Self) T { | ||
| 550 | return self.items[self.items.len - 1]; | ||
| 551 | } | ||
| 552 | 549 | ||
| 553 | /// Returns the last element from the list, or `null` if list is empty. | 550 | /// Returns the last element from the list, or `null` if the list is empty. |
| 554 | pub fn getLastOrNull(self: Self) ?T { | 551 | pub fn getLast(self: Self) ?T { |
| 555 | if (self.items.len == 0) return null; | 552 | if (self.items.len == 0) return null; |
| 556 | return self.getLast(); | 553 | return self.items[self.items.len - 1]; |
| 557 | } | 554 | } |
| 558 | }; | 555 | }; |
| 559 | } | 556 | } |
| ... | @@ -1394,17 +1391,10 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type { | ... | @@ -1394,17 +1391,10 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type { |
| 1394 | return self.allocatedSlice()[self.items.len..]; | 1391 | return self.allocatedSlice()[self.items.len..]; |
| 1395 | } | 1392 | } |
| 1396 | 1393 | ||
| 1397 | /// Return the last element from the list. | 1394 | /// Returns the last element from the list, or `null` if the list is empty. |
| 1398 | /// Asserts that the list is not empty. | 1395 | pub fn getLast(self: Self) ?T { |
| 1399 | pub fn getLast(self: Self) T { | ||
| 1400 | return self.items[self.items.len - 1]; | ||
| 1401 | } | ||
| 1402 | |||
| 1403 | /// Return the last element from the list, or | ||
| 1404 | /// return `null` if list is empty. | ||
| 1405 | pub fn getLastOrNull(self: Self) ?T { | ||
| 1406 | if (self.items.len == 0) return null; | 1396 | if (self.items.len == 0) return null; |
| 1407 | return self.getLast(); | 1397 | return self.items[self.items.len - 1]; |
| 1408 | } | 1398 | } |
| 1409 | 1399 | ||
| 1410 | /// Called when memory growth is necessary. Returns a capacity larger than | 1400 | /// Called when memory growth is necessary. Returns a capacity larger than |
| ... | @@ -2394,22 +2384,11 @@ test "Managed(u32).getLast()" { | ... | @@ -2394,22 +2384,11 @@ test "Managed(u32).getLast()" { |
| 2394 | var list = Managed(u32).init(a); | 2384 | var list = Managed(u32).init(a); |
| 2395 | defer list.deinit(); | 2385 | defer list.deinit(); |
| 2396 | 2386 | ||
| 2397 | try list.append(2); | 2387 | try testing.expectEqual(list.getLast(), null); |
| 2398 | const const_list = list; | ||
| 2399 | try testing.expectEqual(const_list.getLast(), 2); | ||
| 2400 | } | ||
| 2401 | |||
| 2402 | test "Managed(u32).getLastOrNull()" { | ||
| 2403 | const a = testing.allocator; | ||
| 2404 | |||
| 2405 | var list = Managed(u32).init(a); | ||
| 2406 | defer list.deinit(); | ||
| 2407 | |||
| 2408 | try testing.expectEqual(list.getLastOrNull(), null); | ||
| 2409 | 2388 | ||
| 2410 | try list.append(2); | 2389 | try list.append(2); |
| 2411 | const const_list = list; | 2390 | const const_list = list; |
| 2412 | try testing.expectEqual(const_list.getLastOrNull().?, 2); | 2391 | try testing.expectEqual(const_list.getLast().?, 2); |
| 2413 | } | 2392 | } |
| 2414 | 2393 | ||
| 2415 | test "return OutOfMemory when capacity would exceed maximum usize integer value" { | 2394 | test "return OutOfMemory when capacity would exceed maximum usize integer value" { |
lib/std/deque.zig+1-1| ... | @@ -696,7 +696,7 @@ fn fuzzAgainstArrayList(_: void, smith: *std.testing.Smith) anyerror!void { | ... | @@ -696,7 +696,7 @@ fn fuzzAgainstArrayList(_: void, smith: *std.testing.Smith) anyerror!void { |
| 696 | try q.ensureTotalCapacityPrecise(q_gpa, q.len + growth); | 696 | try q.ensureTotalCapacityPrecise(q_gpa, q.len + growth); |
| 697 | }, | 697 | }, |
| 698 | } | 698 | } |
| 699 | try testing.expectEqual(l.getLastOrNull(), q.back()); | 699 | try testing.expectEqual(l.getLast(), q.back()); |
| 700 | try testing.expectEqual( | 700 | try testing.expectEqual( |
| 701 | if (l.items.len > 0) l.items[0] else null, | 701 | if (l.items.len > 0) l.items[0] else null, |
| 702 | q.front(), | 702 | q.front(), |
lib/std/zig/Ast/Render.zig+2-2| ... | @@ -3442,7 +3442,7 @@ const AutoIndentingStream = struct { | ... | @@ -3442,7 +3442,7 @@ const AutoIndentingStream = struct { |
| 3442 | /// Sets current indentation level to be the same as that of the last pushSpace. | 3442 | /// Sets current indentation level to be the same as that of the last pushSpace. |
| 3443 | pub fn enableSpaceMode(ais: *AutoIndentingStream, space: Space) void { | 3443 | pub fn enableSpaceMode(ais: *AutoIndentingStream, space: Space) void { |
| 3444 | if (ais.space_stack.items.len == 0) return; | 3444 | if (ais.space_stack.items.len == 0) return; |
| 3445 | const curr = ais.space_stack.getLast(); | 3445 | const curr = ais.space_stack.getLast().?; |
| 3446 | if (curr.space != space) return; | 3446 | if (curr.space != space) return; |
| 3447 | ais.space_mode = curr.indent_count; | 3447 | ais.space_mode = curr.indent_count; |
| 3448 | } | 3448 | } |
| ... | @@ -3453,7 +3453,7 @@ const AutoIndentingStream = struct { | ... | @@ -3453,7 +3453,7 @@ const AutoIndentingStream = struct { |
| 3453 | 3453 | ||
| 3454 | pub fn lastSpaceModeIndent(ais: *AutoIndentingStream) usize { | 3454 | pub fn lastSpaceModeIndent(ais: *AutoIndentingStream) usize { |
| 3455 | if (ais.space_stack.items.len == 0) return 0; | 3455 | if (ais.space_stack.items.len == 0) return 0; |
| 3456 | return ais.space_stack.getLast().indent_count * ais.indent_delta; | 3456 | return ais.space_stack.getLast().?.indent_count * ais.indent_delta; |
| 3457 | } | 3457 | } |
| 3458 | 3458 | ||
| 3459 | /// Push default indentation | 3459 | /// Push default indentation |
lib/std/zig/WindowsSdk.zig+4-4| ... | @@ -891,7 +891,7 @@ const MsvcLibDir = struct { | ... | @@ -891,7 +891,7 @@ const MsvcLibDir = struct { |
| 891 | 891 | ||
| 892 | lib_dir_buf.appendSliceAssumeCapacity(installation_path); | 892 | lib_dir_buf.appendSliceAssumeCapacity(installation_path); |
| 893 | 893 | ||
| 894 | if (!Dir.path.isSep(lib_dir_buf.getLast())) { | 894 | if (!Dir.path.isSep(lib_dir_buf.getLast().?)) { |
| 895 | try lib_dir_buf.append('\\'); | 895 | try lib_dir_buf.append('\\'); |
| 896 | } | 896 | } |
| 897 | const installation_path_with_trailing_sep_len = lib_dir_buf.items.len; | 897 | const installation_path_with_trailing_sep_len = lib_dir_buf.items.len; |
| ... | @@ -1064,7 +1064,7 @@ const MsvcLibDir = struct { | ... | @@ -1064,7 +1064,7 @@ const MsvcLibDir = struct { |
| 1064 | errdefer msvc_dir.deinit(); | 1064 | errdefer msvc_dir.deinit(); |
| 1065 | 1065 | ||
| 1066 | // String might contain trailing slash, so trim it here | 1066 | // String might contain trailing slash, so trim it here |
| 1067 | if (msvc_dir.items.len > "C:\\".len and msvc_dir.getLast() == '\\') _ = msvc_dir.pop(); | 1067 | if (msvc_dir.items.len > "C:\\".len and msvc_dir.getLast().? == '\\') _ = msvc_dir.pop(); |
| 1068 | 1068 | ||
| 1069 | // Remove `\include` at the end of path | 1069 | // Remove `\include` at the end of path |
| 1070 | if (std.mem.endsWith(u8, msvc_dir.items, "\\include")) { | 1070 | if (std.mem.endsWith(u8, msvc_dir.items, "\\include")) { |
| ... | @@ -1108,7 +1108,7 @@ const MsvcLibDir = struct { | ... | @@ -1108,7 +1108,7 @@ const MsvcLibDir = struct { |
| 1108 | 1108 | ||
| 1109 | try list.appendSlice(VS140COMNTOOLS); // C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools | 1109 | try list.appendSlice(VS140COMNTOOLS); // C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools |
| 1110 | // String might contain trailing slash, so trim it here | 1110 | // String might contain trailing slash, so trim it here |
| 1111 | if (list.items.len > "C:\\".len and list.getLast() == '\\') _ = list.pop(); | 1111 | if (list.items.len > "C:\\".len and list.getLast().? == '\\') _ = list.pop(); |
| 1112 | list.shrinkRetainingCapacity(list.items.len - "\\Common7\\Tools".len); // C:\Program Files (x86)\Microsoft Visual Studio 14.0 | 1112 | list.shrinkRetainingCapacity(list.items.len - "\\Common7\\Tools".len); // C:\Program Files (x86)\Microsoft Visual Studio 14.0 |
| 1113 | break :base_path list; | 1113 | break :base_path list; |
| 1114 | } | 1114 | } |
| ... | @@ -1131,7 +1131,7 @@ const MsvcLibDir = struct { | ... | @@ -1131,7 +1131,7 @@ const MsvcLibDir = struct { |
| 1131 | errdefer path.deinit(); | 1131 | errdefer path.deinit(); |
| 1132 | 1132 | ||
| 1133 | // String might contain trailing slash, so trim it here | 1133 | // String might contain trailing slash, so trim it here |
| 1134 | if (path.items.len > "C:\\".len and path.getLast() == '\\') _ = path.pop(); | 1134 | if (path.items.len > "C:\\".len and path.getLast().? == '\\') _ = path.pop(); |
| 1135 | break :base_path path; | 1135 | break :base_path path; |
| 1136 | } | 1136 | } |
| 1137 | return error.PathNotFound; | 1137 | return error.PathNotFound; |
lib/std/zig/llvm/Builder.zig+4-4| ... | @@ -2310,7 +2310,7 @@ pub fn trailingStrtabString(self: *Builder) Allocator.Error!StrtabString { | ... | @@ -2310,7 +2310,7 @@ pub fn trailingStrtabString(self: *Builder) Allocator.Error!StrtabString { |
| 2310 | } | 2310 | } |
| 2311 | 2311 | ||
| 2312 | pub fn trailingStrtabStringAssumeCapacity(self: *Builder) StrtabString { | 2312 | pub fn trailingStrtabStringAssumeCapacity(self: *Builder) StrtabString { |
| 2313 | const start = self.strtab_string_indices.getLast(); | 2313 | const start = self.strtab_string_indices.getLast().?; |
| 2314 | const bytes: []const u8 = self.strtab_string_bytes.items[start..]; | 2314 | const bytes: []const u8 = self.strtab_string_bytes.items[start..]; |
| 2315 | const gop = self.strtab_string_map.getOrPutAssumeCapacityAdapted(bytes, StrtabString.Adapter{ .builder = self }); | 2315 | const gop = self.strtab_string_map.getOrPutAssumeCapacityAdapted(bytes, StrtabString.Adapter{ .builder = self }); |
| 2316 | if (gop.found_existing) { | 2316 | if (gop.found_existing) { |
| ... | @@ -8905,7 +8905,7 @@ pub fn deinit(self: *Builder) void { | ... | @@ -8905,7 +8905,7 @@ pub fn deinit(self: *Builder) void { |
| 8905 | 8905 | ||
| 8906 | pub fn finishModuleAsm(self: *Builder, aw: *Writer.Allocating) Allocator.Error!void { | 8906 | pub fn finishModuleAsm(self: *Builder, aw: *Writer.Allocating) Allocator.Error!void { |
| 8907 | self.module_asm = aw.toArrayList(); | 8907 | self.module_asm = aw.toArrayList(); |
| 8908 | if (self.module_asm.getLastOrNull()) |last| if (last != '\n') | 8908 | if (self.module_asm.getLast()) |last| if (last != '\n') |
| 8909 | try self.module_asm.append(self.gpa, '\n'); | 8909 | try self.module_asm.append(self.gpa, '\n'); |
| 8910 | } | 8910 | } |
| 8911 | 8911 | ||
| ... | @@ -8951,7 +8951,7 @@ pub fn trailingString(self: *Builder) Allocator.Error!String { | ... | @@ -8951,7 +8951,7 @@ pub fn trailingString(self: *Builder) Allocator.Error!String { |
| 8951 | } | 8951 | } |
| 8952 | 8952 | ||
| 8953 | pub fn trailingStringAssumeCapacity(self: *Builder) String { | 8953 | pub fn trailingStringAssumeCapacity(self: *Builder) String { |
| 8954 | const start = self.string_indices.getLast(); | 8954 | const start = self.string_indices.getLast().?; |
| 8955 | const bytes: []const u8 = self.string_bytes.items[start..]; | 8955 | const bytes: []const u8 = self.string_bytes.items[start..]; |
| 8956 | const gop = self.string_map.getOrPutAssumeCapacityAdapted(bytes, String.Adapter{ .builder = self }); | 8956 | const gop = self.string_map.getOrPutAssumeCapacityAdapted(bytes, String.Adapter{ .builder = self }); |
| 8957 | if (gop.found_existing) { | 8957 | if (gop.found_existing) { |
| ... | @@ -12150,7 +12150,7 @@ pub fn trailingMetadataString(self: *Builder) Allocator.Error!Metadata.String { | ... | @@ -12150,7 +12150,7 @@ pub fn trailingMetadataString(self: *Builder) Allocator.Error!Metadata.String { |
| 12150 | } | 12150 | } |
| 12151 | 12151 | ||
| 12152 | pub fn trailingMetadataStringAssumeCapacity(self: *Builder) Metadata.String { | 12152 | pub fn trailingMetadataStringAssumeCapacity(self: *Builder) Metadata.String { |
| 12153 | const start = self.metadata_string_indices.getLast(); | 12153 | const start = self.metadata_string_indices.getLast().?; |
| 12154 | const bytes: []const u8 = self.metadata_string_bytes.items[start..]; | 12154 | const bytes: []const u8 = self.metadata_string_bytes.items[start..]; |
| 12155 | assert(bytes.len > 0); | 12155 | assert(bytes.len > 0); |
| 12156 | const gop = self.metadata_string_map.getOrPutAssumeCapacityAdapted(bytes, Metadata.String.Adapter{ .builder = self }); | 12156 | const gop = self.metadata_string_map.getOrPutAssumeCapacityAdapted(bytes, Metadata.String.Adapter{ .builder = self }); |
src/codegen/llvm.zig+1-1| ... | @@ -747,7 +747,7 @@ pub const Object = struct { | ... | @@ -747,7 +747,7 @@ pub const Object = struct { |
| 747 | b.module_asm.appendSliceAssumeCapacity(assembly); | 747 | b.module_asm.appendSliceAssumeCapacity(assembly); |
| 748 | b.module_asm.appendAssumeCapacity('\n'); | 748 | b.module_asm.appendAssumeCapacity('\n'); |
| 749 | } | 749 | } |
| 750 | if (b.module_asm.getLastOrNull()) |last| { | 750 | if (b.module_asm.getLast()) |last| { |
| 751 | if (last != '\n') try b.module_asm.append(gpa, '\n'); | 751 | if (last != '\n') try b.module_asm.append(gpa, '\n'); |
| 752 | } | 752 | } |
| 753 | } | 753 | } |
src/codegen/spirv/CodeGen.zig+2-2| ... | @@ -4829,7 +4829,7 @@ fn structuredBreak(cg: *CodeGen, target_block: Id) !void { | ... | @@ -4829,7 +4829,7 @@ fn structuredBreak(cg: *CodeGen, target_block: Id) !void { |
| 4829 | assert(cg.control_flow == .structured); | 4829 | assert(cg.control_flow == .structured); |
| 4830 | 4830 | ||
| 4831 | const gpa = cg.module.gpa; | 4831 | const gpa = cg.module.gpa; |
| 4832 | const sblock = cg.control_flow.structured.block_stack.getLast(); | 4832 | const sblock = cg.control_flow.structured.block_stack.getLast().?; |
| 4833 | const merge_block = switch (sblock.*) { | 4833 | const merge_block = switch (sblock.*) { |
| 4834 | .selection => |*merge| blk: { | 4834 | .selection => |*merge| blk: { |
| 4835 | const merge_label = cg.module.allocId(); | 4835 | const merge_label = cg.module.allocId(); |
| ... | @@ -5044,7 +5044,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index) | ... | @@ -5044,7 +5044,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index) |
| 5044 | .operand_2 = this_block, | 5044 | .operand_2 = this_block, |
| 5045 | }); | 5045 | }); |
| 5046 | 5046 | ||
| 5047 | const sblock = cf.block_stack.getLast(); | 5047 | const sblock = cf.block_stack.getLast().?; |
| 5048 | 5048 | ||
| 5049 | if (ty.isNoReturn(zcu)) { | 5049 | if (ty.isNoReturn(zcu)) { |
| 5050 | // If this block is noreturn, this instruction is the last of a block, | 5050 | // If this block is noreturn, this instruction is the last of a block, |
src/codegen/x86_64/CodeGen.zig+2-2| ... | @@ -2065,7 +2065,7 @@ fn gen( | ... | @@ -2065,7 +2065,7 @@ fn gen( |
| 2065 | 2065 | ||
| 2066 | const epilogue = if (self.epilogue_relocs.items.len > 0) epilogue: { | 2066 | const epilogue = if (self.epilogue_relocs.items.len > 0) epilogue: { |
| 2067 | var last_inst: Mir.Inst.Index = @intCast(self.mir_instructions.len - 1); | 2067 | var last_inst: Mir.Inst.Index = @intCast(self.mir_instructions.len - 1); |
| 2068 | while (self.epilogue_relocs.getLastOrNull() == last_inst) { | 2068 | while (self.epilogue_relocs.getLast() == last_inst) { |
| 2069 | self.epilogue_relocs.items.len -= 1; | 2069 | self.epilogue_relocs.items.len -= 1; |
| 2070 | self.mir_instructions.set(last_inst, .{ | 2070 | self.mir_instructions.set(last_inst, .{ |
| 2071 | .tag = .pseudo, | 2071 | .tag = .pseudo, |
| ... | @@ -176545,7 +176545,7 @@ fn lowerBlock(self: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index | ... | @@ -176545,7 +176545,7 @@ fn lowerBlock(self: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index |
| 176545 | defer block_data.value.deinit(self.gpa); | 176545 | defer block_data.value.deinit(self.gpa); |
| 176546 | if (block_data.value.relocs.items.len > 0) { | 176546 | if (block_data.value.relocs.items.len > 0) { |
| 176547 | var last_inst: Mir.Inst.Index = @intCast(self.mir_instructions.len - 1); | 176547 | var last_inst: Mir.Inst.Index = @intCast(self.mir_instructions.len - 1); |
| 176548 | while (block_data.value.relocs.getLastOrNull() == last_inst) { | 176548 | while (block_data.value.relocs.getLast() == last_inst) { |
| 176549 | block_data.value.relocs.items.len -= 1; | 176549 | block_data.value.relocs.items.len -= 1; |
| 176550 | self.mir_instructions.set(last_inst, .{ | 176550 | self.mir_instructions.set(last_inst, .{ |
| 176551 | .tag = .pseudo, | 176551 | .tag = .pseudo, |