Remove .string branch if using .alloc_always
This commit is contained in:
parent
902fcd4447
commit
6aac0bff2b
1 changed files with 7 additions and 6 deletions
|
|
@ -102,6 +102,7 @@ pub fn scrobbleIngest(allocator: std.mem.Allocator, input: []const u8) ![]Data.U
|
|||
_ = try scanner.next();
|
||||
try scanner.skipValue();
|
||||
const lfw_date_token = try scanner.nextAlloc(allocator, .alloc_if_needed);
|
||||
// Skip over human-readable date format and then leave
|
||||
try scanner.skipValue();
|
||||
try scanner.skipValue();
|
||||
_ = try scanner.next();
|
||||
|
|
@ -148,7 +149,7 @@ pub fn scrobbleIngest(allocator: std.mem.Allocator, input: []const u8) ![]Data.U
|
|||
freeAllocated(allocator, key_token);
|
||||
const track = try scanner.nextAlloc(allocator, .alloc_always);
|
||||
@field(r, "track") = switch (track) {
|
||||
inline .string, .allocated_string => |slice| slice,
|
||||
.allocated_string => |slice| slice,
|
||||
.null => null,
|
||||
else => return error.UnexpectedToken,
|
||||
};
|
||||
|
|
@ -165,13 +166,13 @@ pub fn scrobbleIngest(allocator: std.mem.Allocator, input: []const u8) ![]Data.U
|
|||
// Leave object
|
||||
_ = try scanner.next();
|
||||
break :blk switch (lfw_artist_token) {
|
||||
inline .string, .allocated_string => |slice| slice,
|
||||
.allocated_string => |slice| slice,
|
||||
else => return error.UnexpectedToken,
|
||||
};
|
||||
} else blk: {
|
||||
const artist_token = try scanner.nextAlloc(allocator, .alloc_always);
|
||||
break :blk switch (artist_token) {
|
||||
inline .string, .allocated_string => |slice| slice,
|
||||
.allocated_string => |slice| slice,
|
||||
.null => null,
|
||||
else => return error.UnexpectedToken,
|
||||
};
|
||||
|
|
@ -191,13 +192,13 @@ pub fn scrobbleIngest(allocator: std.mem.Allocator, input: []const u8) ![]Data.U
|
|||
// Leave object
|
||||
_ = try scanner.next();
|
||||
break :blk switch (lfw_album_token) {
|
||||
inline .string, .allocated_string => |slice| slice,
|
||||
.allocated_string => |slice| slice,
|
||||
else => return error.UnexpectedToken,
|
||||
};
|
||||
} else blk: {
|
||||
const album_token = try scanner.nextAlloc(allocator, .alloc_always);
|
||||
break :blk switch (album_token) {
|
||||
inline .string, .allocated_string => |slice| slice,
|
||||
.allocated_string => |slice| slice,
|
||||
.null => null,
|
||||
else => return error.UnexpectedToken,
|
||||
};
|
||||
|
|
@ -208,7 +209,7 @@ pub fn scrobbleIngest(allocator: std.mem.Allocator, input: []const u8) ![]Data.U
|
|||
freeAllocated(allocator, key_token);
|
||||
const reason_end = try scanner.nextAlloc(allocator, .alloc_always);
|
||||
@field(r, "reason_end") = switch (reason_end) {
|
||||
inline .string, .allocated_string => |slice| slice,
|
||||
.allocated_string => |slice| slice,
|
||||
.null => null,
|
||||
else => return error.UnexpectedToken,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue