summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2021-10-23 14:28:27 +0200
committerGravatar Vincent Rischmann2021-10-23 16:48:06 +0200
commit8757dd0458eba961a7837cc00210e65c639bd82b (patch)
tree26ab3255a25d584791b90080e7d4fb77770b95d9
parentdocument BindMarker (diff)
downloadzig-sqlite-8757dd0458eba961a7837cc00210e65c639bd82b.tar.gz
zig-sqlite-8757dd0458eba961a7837cc00210e65c639bd82b.tar.xz
zig-sqlite-8757dd0458eba961a7837cc00210e65c639bd82b.zip
query: use a switch instead of if/else chains
-rw-r--r--query.zig19
1 files changed, 11 insertions, 8 deletions
diff --git a/query.zig b/query.zig
index 6d9c4eb..e4113bd 100644
--- a/query.zig
+++ b/query.zig
@@ -132,14 +132,17 @@ pub const ParsedQuery = struct {
132 } 132 }
133 133
134 // The last character was ? so this must be an untyped bind marker. 134 // The last character was ? so this must be an untyped bind marker.
135 if (state == .BindMarker) { 135 switch (state) {
136 parsed_query.bind_markers[parsed_query.nb_bind_markers].typed = null; 136 .BindMarker => {
137 parsed_query.nb_bind_markers += 1; 137 parsed_query.bind_markers[parsed_query.nb_bind_markers].typed = null;
138 } else if (state == .BindMarkerIdentifier) { 138 parsed_query.nb_bind_markers += 1;
139 parsed_query.bind_markers[parsed_query.nb_bind_markers].identifier = std.fmt.comptimePrint("{s}", .{current_bind_marker_id[0..current_bind_marker_id_pos]}); 139 },
140 parsed_query.nb_bind_markers += 1; 140 .BindMarkerIdentifier => {
141 } else if (state == .BindMarkerType) { 141 parsed_query.bind_markers[parsed_query.nb_bind_markers].identifier = std.fmt.comptimePrint("{s}", .{current_bind_marker_id[0..current_bind_marker_id_pos]});
142 @compileError("invalid final state " ++ @tagName(state) ++ ", this means you wrote an incomplete bind marker type"); 142 parsed_query.nb_bind_markers += 1;
143 },
144 .Start => {},
145 else => @compileError("invalid final state " ++ @tagName(state) ++ ", this means you wrote an incomplete bind marker type"),
143 } 146 }
144 147
145 mem.copy(u8, &parsed_query.query, &buf); 148 mem.copy(u8, &parsed_query.query, &buf);