Commit 3cf302a71d

daurnimator <quae@daurnimator.com>
2020-03-31 16:25:25
Tidy up some mem.spanZ use-sites now that null is accepted
1 parent b1eb831
Changed files (3)
lib
src-self-hosted
lib/std/debug.zig
@@ -1254,7 +1254,7 @@ pub const DebugInfo = struct {
                     if (context.address >= seg_start and context.address < seg_end) {
                         // Android libc uses NULL instead of an empty string to mark the
                         // main program
-                        context.name = if (info.dlpi_name) |dlpi_name| mem.spanZ(dlpi_name) else "";
+                        context.name = mem.spanZ(info.dlpi_name) orelse "";
                         context.base_address = info.dlpi_addr;
                         // Stop the iteration
                         return error.Found;
lib/std/os.zig
@@ -1078,7 +1078,7 @@ pub fn execvpe_expandArg0(
     mem.set(?[*:0]u8, argv_buf, null);
     defer {
         for (argv_buf) |arg| {
-            const arg_buf = if (arg) |ptr| mem.spanZ(ptr) else break;
+            const arg_buf = mem.spanZ(arg) orelse break;
             allocator.free(arg_buf);
         }
         allocator.free(argv_buf);
src-self-hosted/stage2.zig
@@ -689,12 +689,11 @@ fn stage2CrossTarget(
     mcpu_oz: ?[*:0]const u8,
     dynamic_linker_oz: ?[*:0]const u8,
 ) !CrossTarget {
-    const zig_triple = if (zig_triple_oz) |zig_triple_z| mem.spanZ(zig_triple_z) else "native";
-    const mcpu = if (mcpu_oz) |mcpu_z| mem.spanZ(mcpu_z) else null;
-    const dynamic_linker = if (dynamic_linker_oz) |dl_z| mem.spanZ(dl_z) else null;
+    const mcpu = mem.spanZ(mcpu_oz);
+    const dynamic_linker = mem.spanZ(dynamic_linker_oz);
     var diags: CrossTarget.ParseOptions.Diagnostics = .{};
     const target: CrossTarget = CrossTarget.parse(.{
-        .arch_os_abi = zig_triple,
+        .arch_os_abi = mem.spanZ(zig_triple_oz) orelse "native",
         .cpu_features = mcpu,
         .dynamic_linker = dynamic_linker,
         .diagnostics = &diags,