better null check syntax

Co-authored-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
Pierre Tachoire
2023-11-27 17:52:32 +01:00
parent 8d6f18744e
commit c4c6cfa044
2 changed files with 8 additions and 8 deletions

View File

@@ -42,14 +42,14 @@ pub const DOMImplementation = struct {
) !*parser.Document {
_ = self;
var cnamespace: ?[:0]const u8 = null;
if (namespace != null) {
cnamespace = try allocator.dupeZ(u8, namespace.?);
if (namespace) |ns| {
cnamespace = try allocator.dupeZ(u8, ns);
defer allocator.free(cnamespace.?);
}
var cqname: ?[:0]const u8 = null;
if (qname != null) {
cqname = try allocator.dupeZ(u8, qname.?);
if (qname) |qn| {
cqname = try allocator.dupeZ(u8, qn);
defer allocator.free(cqname.?);
}