| ... | @@ -1182,10 +1182,18 @@ fn emitProducerSection(gpa: Allocator, binary_bytes: *std.ArrayListUnmanaged(u8) | ... | @@ -1182,10 +1182,18 @@ fn emitProducerSection(gpa: Allocator, binary_bytes: *std.ArrayListUnmanaged(u8) |
| 1182 | | 1182 | |
| 1183 | fn splitSegmentName(name: []const u8) struct { []const u8, []const u8 } { | 1183 | fn splitSegmentName(name: []const u8) struct { []const u8, []const u8 } { |
| 1184 | const start = @intFromBool(name.len >= 1 and name[0] == '.'); | 1184 | const start = @intFromBool(name.len >= 1 and name[0] == '.'); |
| 1185 | const pivot = mem.indexOfScalarPos(u8, name, start, '.') orelse 0; | 1185 | const pivot = mem.indexOfScalarPos(u8, name, start, '.') orelse name.len; |
| 1186 | return .{ name[0..pivot], name[pivot..] }; | 1186 | return .{ name[0..pivot], name[pivot..] }; |
| 1187 | } | 1187 | } |
| 1188 | | 1188 | |
| | 1189 | test splitSegmentName { |
| | 1190 | { |
| | 1191 | const a, const b = splitSegmentName(".data"); |
| | 1192 | try std.testing.expectEqualStrings(".data", a); |
| | 1193 | try std.testing.expectEqualStrings("", b); |
| | 1194 | } |
| | 1195 | } |
| | 1196 | |
| 1189 | fn wantSegmentMerge( | 1197 | fn wantSegmentMerge( |
| 1190 | wasm: *const Wasm, | 1198 | wasm: *const Wasm, |
| 1191 | a_id: Wasm.DataSegmentId, | 1199 | a_id: Wasm.DataSegmentId, |