authorgravatar for saurabh.m@proton.meSaurabh Mishra <saurabh.m@proton.me> 2026-08-07 07:30:10+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-07 07:30:10+02:00
log21f23814383ff8060a6b983c5ff9e47b5f1853ba
treeb34b8869d83fddf444d66cefd676f058118dce67
parent2b242157b875573c68e92ebe4b8dbddc7f01ffdf

std.ArrayListUnmanaged: `last` and `lastPtr` methods (#36318)

ArrayList: - `getLastOrNull` has been deprecated and renamed to `last` - `getLast` has been removed in favor of `last` combined with `.?` - `lastPtr` has been added which returns `?*T` Upgrade guide: ```zig if (list.getLastOrNull()) |foo| { // ... } const foo = list.getLast(); ``` ⬇️ ```zig if (list.last()) |foo| { // ... } const foo = list.last().?; ``` Co-authored-by: Ryan Liptak <squeek502@hotmail.com> Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36318 Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>

12 files changed, 47 insertions(+), 38 deletions(-)

lib/compiler/Maker.zig+1-1
...@@ -2666,7 +2666,7 @@ fn makeStep(...@@ -2666,7 +2666,7 @@ fn makeStep(
2666 maker.available_rss += max_rss;2666 maker.available_rss += max_rss;
2667 dispatch_set.ensureUnusedCapacity(gpa, maker.memory_blocked_steps.items.len) catch2667 dispatch_set.ensureUnusedCapacity(gpa, maker.memory_blocked_steps.items.len) catch
2668 @panic("TODO eliminate memory allocation here");2668 @panic("TODO eliminate memory allocation here");
2669 while (maker.memory_blocked_steps.getLast()) |candidate_index| {2669 while (maker.memory_blocked_steps.last()) |candidate_index| {
2670 const candidate_max_rss = candidate_index.ptr(c).max_rss.toBytes();2670 const candidate_max_rss = candidate_index.ptr(c).max_rss.toBytes();
2671 if (maker.available_rss < candidate_max_rss) break;2671 if (maker.available_rss < candidate_max_rss) break;
2672 assert(maker.memory_blocked_steps.pop() == candidate_index);2672 assert(maker.memory_blocked_steps.pop() == candidate_index);
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.last().? == '.') {
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;
210210
211 const in_code_block = p.pending_blocks.items.len > 0 and211 const in_code_block = p.pending_blocks.items.len > 0 and
212 p.pending_blocks.getLast().?.tag == .code_block;212 p.pending_blocks.last().?.tag == .code_block;
213 const code_block_end = in_code_block and213 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 or215 // 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 and225 if (maybe_block_start == null and
226 !isBlank(rest_line) and226 !isBlank(rest_line) and
227 p.pending_blocks.items.len > 0 and227 p.pending_blocks.items.len > 0 and
228 p.pending_blocks.getLast().?.tag == .paragraph)228 p.pending_blocks.last().?.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 and237 if (maybe_block_start != null and
238 p.pending_blocks.items.len > 0 and238 p.pending_blocks.items.len > 0 and
239 p.pending_blocks.getLast().?.tag == .paragraph)239 p.pending_blocks.last().?.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;
261261
262 const can_accept = if (p.pending_blocks.getLast()) |last_pending_block|262 const can_accept = if (p.pending_blocks.last()) |last_pending_block|
263 last_pending_block.canAccept()263 last_pending_block.canAccept()
264 else264 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 the273 // 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 be274 // 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.last().?.tag == .list_item)
277 p.pending_blocks.items.len - 2277 p.pending_blocks.items.len - 2
278 else278 else
279 null;279 null;
...@@ -368,7 +368,7 @@ const BlockStart = struct {...@@ -368,7 +368,7 @@ const BlockStart = struct {
368};368};
369369
370fn appendBlockStart(p: *Parser, block_start: BlockStart) !void {370fn appendBlockStart(p: *Parser, block_start: BlockStart) !void {
371 if (p.pending_blocks.getLast()) |last_pending_block| {371 if (p.pending_blocks.last()) |last_pending_block| {
372 // Close the last block if it is a list and the new block is not a list item372 // 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 and374 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 }
385385
386 if (p.pending_blocks.getLast()) |last_pending_block| {386 if (p.pending_blocks.last()) |last_pending_block| {
387 // If the last block is a list or list item, check for tightness based387 // 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 no401 // 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 and403 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.last().?.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 {
417417
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.last().?.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 }
431431
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.last().?.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 column441 // 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.last().?];
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[@backingInt(header_cell)].table_cell;447 const cell_data = &datas[@backingInt(header_cell)].table_cell;
lib/std/array_list.zig+17-8
...@@ -544,14 +544,22 @@ pub fn AlignedManaged(comptime T: type, comptime alignment: ?mem.Alignment) type...@@ -544,14 +544,22 @@ 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 }
546546
547 /// Deprecated in favor of `getLast`547 /// Deprecated in favor of `last`
548 pub const getLastOrNull = getLast;548 pub const getLastOrNull = last;
549549
550 /// Returns the last element from the list, or `null` if the list is empty.550 /// Returns the last element from the list, or `null` if the list is
551 pub fn getLast(self: Self) ?T {551 /// empty.
552 pub fn last(self: Self) ?T {
552 if (self.items.len == 0) return null;553 if (self.items.len == 0) return null;
553 return self.items[self.items.len - 1];554 return self.items[self.items.len - 1];
554 }555 }
556
557 /// Returns a pointer to the last element from the list, or `null` if
558 /// the list is empty.
559 pub fn lastPtr(self: Self) ?*T {
560 if (self.items.len == 0) return null;
561 return &self.items[self.items.len - 1];
562 }
555 };563 };
556}564}
557565
...@@ -1391,15 +1399,16 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type {...@@ -1391,15 +1399,16 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type {
1391 return self.allocatedSlice()[self.items.len..];1399 return self.allocatedSlice()[self.items.len..];
1392 }1400 }
13931401
1394 /// Deprecated in favor of `last`.1402 /// Returns the last element from the list, or `null` if the list is
1395 pub fn getLast(self: Self) ?T {1403 /// empty.
1404 pub fn last(self: Self) ?T {
1396 if (self.items.len == 0) return null;1405 if (self.items.len == 0) return null;
1397 return self.items[self.items.len - 1];1406 return self.items[self.items.len - 1];
1398 }1407 }
13991408
1400 /// Returns a pointer to the last element from the list, or `null` if1409 /// Returns a pointer to the last element from the list, or `null` if
1401 /// the list is empty.1410 /// the list is empty.
1402 pub fn last(self: Self) ?*T {1411 pub fn lastPtr(self: Self) ?*T {
1403 if (self.items.len == 0) return null;1412 if (self.items.len == 0) return null;
1404 return &self.items[self.items.len - 1];1413 return &self.items[self.items.len - 1];
1405 }1414 }
...@@ -2398,7 +2407,7 @@ test "last" {...@@ -2398,7 +2407,7 @@ test "last" {
2398 try testing.expectEqual(list.last(), null);2407 try testing.expectEqual(list.last(), null);
23992408
2400 try list.append(a, 2);2409 try list.append(a, 2);
2401 try testing.expectEqual(list.last().?.*, 2);2410 try testing.expectEqual(list.last().?, 2);
2402}2411}
24032412
2404test "return OutOfMemory when capacity would exceed maximum usize integer value" {2413test "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.getLast(), q.back());699 try testing.expectEqual(l.last(), 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
...@@ -3459,7 +3459,7 @@ const AutoIndentingStream = struct {...@@ -3459,7 +3459,7 @@ const AutoIndentingStream = struct {
3459 /// Sets current indentation level to be the same as that of the last pushSpace.3459 /// Sets current indentation level to be the same as that of the last pushSpace.
3460 pub fn enableSpaceMode(ais: *AutoIndentingStream, space: Space) void {3460 pub fn enableSpaceMode(ais: *AutoIndentingStream, space: Space) void {
3461 if (ais.space_stack.items.len == 0) return;3461 if (ais.space_stack.items.len == 0) return;
3462 const curr = ais.space_stack.getLast().?;3462 const curr = ais.space_stack.last().?;
3463 if (curr.space != space) return;3463 if (curr.space != space) return;
3464 ais.space_mode = curr.indent_count;3464 ais.space_mode = curr.indent_count;
3465 }3465 }
...@@ -3470,7 +3470,7 @@ const AutoIndentingStream = struct {...@@ -3470,7 +3470,7 @@ const AutoIndentingStream = struct {
34703470
3471 pub fn lastSpaceModeIndent(ais: *AutoIndentingStream) usize {3471 pub fn lastSpaceModeIndent(ais: *AutoIndentingStream) usize {
3472 if (ais.space_stack.items.len == 0) return 0;3472 if (ais.space_stack.items.len == 0) return 0;
3473 return ais.space_stack.getLast().?.indent_count * ais.indent_delta;3473 return ais.space_stack.last().?.indent_count * ais.indent_delta;
3474 }3474 }
34753475
3476 /// Push default indentation3476 /// Push default indentation
lib/std/zig/WindowsSdk.zig+4-4
...@@ -891,7 +891,7 @@ const MsvcLibDir = struct {...@@ -891,7 +891,7 @@ const MsvcLibDir = struct {
891891
892 lib_dir_buf.appendSliceAssumeCapacity(installation_path);892 lib_dir_buf.appendSliceAssumeCapacity(installation_path);
893893
894 if (!Dir.path.isSep(lib_dir_buf.getLast().?)) {894 if (!Dir.path.isSep(lib_dir_buf.last().?)) {
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();
10651065
1066 // String might contain trailing slash, so trim it here1066 // 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.last().? == '\\') _ = msvc_dir.pop();
10681068
1069 // Remove `\include` at the end of path1069 // 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 {
11081108
1109 try list.appendSlice(VS140COMNTOOLS); // C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools1109 try list.appendSlice(VS140COMNTOOLS); // C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools
1110 // String might contain trailing slash, so trim it here1110 // 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.last().? == '\\') _ = list.pop();
1112 list.shrinkRetainingCapacity(list.items.len - "\\Common7\\Tools".len); // C:\Program Files (x86)\Microsoft Visual Studio 14.01112 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();
11321132
1133 // String might contain trailing slash, so trim it here1133 // 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.last().? == '\\') _ = 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
...@@ -2962,7 +2962,7 @@ pub fn trailingStrtabString(self: *Builder) Allocator.Error!StrtabString {...@@ -2962,7 +2962,7 @@ pub fn trailingStrtabString(self: *Builder) Allocator.Error!StrtabString {
2962}2962}
29632963
2964pub fn trailingStrtabStringAssumeCapacity(self: *Builder) StrtabString {2964pub fn trailingStrtabStringAssumeCapacity(self: *Builder) StrtabString {
2965 const start = self.strtab_string_indices.getLast().?;2965 const start = self.strtab_string_indices.last().?;
2966 const bytes: []const u8 = self.strtab_string_bytes.items[start..];2966 const bytes: []const u8 = self.strtab_string_bytes.items[start..];
2967 const gop = self.strtab_string_map.getOrPutAssumeCapacityAdapted(bytes, StrtabString.Adapter{ .builder = self });2967 const gop = self.strtab_string_map.getOrPutAssumeCapacityAdapted(bytes, StrtabString.Adapter{ .builder = self });
2968 if (gop.found_existing) {2968 if (gop.found_existing) {
...@@ -9765,7 +9765,7 @@ pub fn deinit(self: *Builder) void {...@@ -9765,7 +9765,7 @@ pub fn deinit(self: *Builder) void {
97659765
9766pub fn finishModuleAsm(self: *Builder, aw: *Writer.Allocating) Allocator.Error!void {9766pub fn finishModuleAsm(self: *Builder, aw: *Writer.Allocating) Allocator.Error!void {
9767 self.module_asm = aw.toArrayList();9767 self.module_asm = aw.toArrayList();
9768 if (self.module_asm.getLast()) |last| if (last != '\n')9768 if (self.module_asm.last()) |last| if (last != '\n')
9769 try self.module_asm.append(self.gpa, '\n');9769 try self.module_asm.append(self.gpa, '\n');
9770}9770}
97719771
...@@ -9811,7 +9811,7 @@ pub fn trailingString(self: *Builder) Allocator.Error!String {...@@ -9811,7 +9811,7 @@ pub fn trailingString(self: *Builder) Allocator.Error!String {
9811}9811}
98129812
9813pub fn trailingStringAssumeCapacity(self: *Builder) String {9813pub fn trailingStringAssumeCapacity(self: *Builder) String {
9814 const start = self.string_indices.getLast().?;9814 const start = self.string_indices.last().?;
9815 const bytes: []const u8 = self.string_bytes.items[start..];9815 const bytes: []const u8 = self.string_bytes.items[start..];
9816 const gop = self.string_map.getOrPutAssumeCapacityAdapted(bytes, String.Adapter{ .builder = self });9816 const gop = self.string_map.getOrPutAssumeCapacityAdapted(bytes, String.Adapter{ .builder = self });
9817 if (gop.found_existing) {9817 if (gop.found_existing) {
...@@ -13042,7 +13042,7 @@ pub fn trailingMetadataString(self: *Builder) Allocator.Error!Metadata.String {...@@ -13042,7 +13042,7 @@ pub fn trailingMetadataString(self: *Builder) Allocator.Error!Metadata.String {
13042}13042}
1304313043
13044pub fn trailingMetadataStringAssumeCapacity(self: *Builder) Metadata.String {13044pub fn trailingMetadataStringAssumeCapacity(self: *Builder) Metadata.String {
13045 const start = self.metadata_string_indices.getLast().?;13045 const start = self.metadata_string_indices.last().?;
13046 const bytes: []const u8 = self.metadata_string_bytes.items[start..];13046 const bytes: []const u8 = self.metadata_string_bytes.items[start..];
13047 assert(bytes.len > 0);13047 assert(bytes.len > 0);
13048 const gop = self.metadata_string_map.getOrPutAssumeCapacityAdapted(bytes, Metadata.String.Adapter{ .builder = self });13048 const gop = self.metadata_string_map.getOrPutAssumeCapacityAdapted(bytes, Metadata.String.Adapter{ .builder = self });
src/codegen/llvm.zig+1-1
...@@ -618,7 +618,7 @@ pub const Object = struct {...@@ -618,7 +618,7 @@ pub const Object = struct {
618 b.module_asm.appendSliceAssumeCapacity(assembly);618 b.module_asm.appendSliceAssumeCapacity(assembly);
619 b.module_asm.appendAssumeCapacity('\n');619 b.module_asm.appendAssumeCapacity('\n');
620 }620 }
621 if (b.module_asm.getLast()) |last| {621 if (b.module_asm.last()) |last| {
622 if (last != '\n') try b.module_asm.append(gpa, '\n');622 if (last != '\n') try b.module_asm.append(gpa, '\n');
623 }623 }
624 }624 }
src/codegen/spirv/CodeGen.zig+2-2
...@@ -7280,7 +7280,7 @@ fn structuredBreak(cg: *CodeGen, target_block: Id) !void {...@@ -7280,7 +7280,7 @@ fn structuredBreak(cg: *CodeGen, target_block: Id) !void {
7280 if (cg.block_terminated) return;7280 if (cg.block_terminated) return;
72817281
7282 const gpa = cg.gpa;7282 const gpa = cg.gpa;
7283 const sblock = cg.block_stack.getLast().?;7283 const sblock = cg.block_stack.last().?;
7284 const merge_block = switch (sblock.*) {7284 const merge_block = switch (sblock.*) {
7285 .selection => |*merge| blk: {7285 .selection => |*merge| blk: {
7286 const merge_label = cg.allocId();7286 const merge_label = cg.allocId();
...@@ -7447,7 +7447,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)...@@ -7447,7 +7447,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)
7447 .operand_2 = this_block,7447 .operand_2 = this_block,
7448 });7448 });
74497449
7450 const sblock = cg.block_stack.getLast().?;7450 const sblock = cg.block_stack.last().?;
74517451
7452 if (ty.isNoReturn(zcu)) {7452 if (ty.isNoReturn(zcu)) {
7453 // If this block is noreturn, this instruction is the last of a block,7453 // If this block is noreturn, this instruction is the last of a block,
src/codegen/x86_64/CodeGen.zig+2-2
...@@ -2152,7 +2152,7 @@ fn gen(...@@ -2152,7 +2152,7 @@ fn gen(
21522152
2153 const epilogue = if (self.epilogue_relocs.items.len > 0) epilogue: {2153 const epilogue = if (self.epilogue_relocs.items.len > 0) epilogue: {
2154 var last_inst: Mir.Inst.Index = @intCast(self.mir_instructions.len - 1);2154 var last_inst: Mir.Inst.Index = @intCast(self.mir_instructions.len - 1);
2155 while (self.epilogue_relocs.getLast() == last_inst) {2155 while (self.epilogue_relocs.last() == last_inst) {
2156 self.epilogue_relocs.items.len -= 1;2156 self.epilogue_relocs.items.len -= 1;
2157 self.mir_instructions.set(last_inst, .{2157 self.mir_instructions.set(last_inst, .{
2158 .tag = .pseudo,2158 .tag = .pseudo,
...@@ -176978,7 +176978,7 @@ fn lowerBlock(self: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index...@@ -176978,7 +176978,7 @@ fn lowerBlock(self: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index
176978 defer block_data.value.deinit(self.gpa);176978 defer block_data.value.deinit(self.gpa);
176979 if (block_data.value.relocs.items.len > 0) {176979 if (block_data.value.relocs.items.len > 0) {
176980 var last_inst: Mir.Inst.Index = @intCast(self.mir_instructions.len - 1);176980 var last_inst: Mir.Inst.Index = @intCast(self.mir_instructions.len - 1);
176981 while (block_data.value.relocs.getLast() == last_inst) {176981 while (block_data.value.relocs.last() == last_inst) {
176982 block_data.value.relocs.items.len -= 1;176982 block_data.value.relocs.items.len -= 1;
176983 self.mir_instructions.set(last_inst, .{176983 self.mir_instructions.set(last_inst, .{
176984 .tag = .pseudo,176984 .tag = .pseudo,
tools/bsp.zig+1-1
...@@ -21,7 +21,7 @@ pub fn main(init: std.process.Init) !void {...@@ -21,7 +21,7 @@ pub fn main(init: std.process.Init) !void {
21 }21 }
22 if (maker_args.items.len < 1) try maker_args.append(arena, "zig");22 if (maker_args.items.len < 1) try maker_args.append(arena, "zig");
23 if (maker_args.items.len < 2) try maker_args.append(arena, "build");23 if (maker_args.items.len < 2) try maker_args.append(arena, "build");
24 if (!std.mem.eql(u8, maker_args.last().?.*, "--listen=-")) try maker_args.append(arena, "--listen=-");24 if (!std.mem.eql(u8, maker_args.last().?, "--listen=-")) try maker_args.append(arena, "--listen=-");
2525
26 log.debug("cmd: {f}", .{std.zig.SubprocessCommand{26 log.debug("cmd: {f}", .{std.zig.SubprocessCommand{
27 .argv = maker_args.items,27 .argv = maker_args.items,