diff options
| author | 2021-09-07 01:04:44 +0200 | |
|---|---|---|
| committer | 2021-09-07 01:04:44 +0200 | |
| commit | 21e8477b206c84f939f4b3dea8288a97474cce20 (patch) | |
| tree | bd63753b6489e99482ebdb49a1b298720316c7f8 /sqlite.zig | |
| parent | Stop using anytype in the public API. (diff) | |
| download | zig-sqlite-21e8477b206c84f939f4b3dea8288a97474cce20.tar.gz zig-sqlite-21e8477b206c84f939f4b3dea8288a97474cce20.tar.xz zig-sqlite-21e8477b206c84f939f4b3dea8288a97474cce20.zip | |
more minor cleanups
Diffstat (limited to '')
| -rw-r--r-- | sqlite.zig | 14 |
1 files changed, 4 insertions, 10 deletions
| @@ -781,8 +781,7 @@ pub fn Iterator(comptime Type: type) type { | |||
| 781 | 781 | ||
| 782 | // dupeWithSentinel is like dupe/dupeZ but allows for any sentinel value. | 782 | // dupeWithSentinel is like dupe/dupeZ but allows for any sentinel value. |
| 783 | fn dupeWithSentinel(comptime SliceType: type, allocator: *mem.Allocator, data: []const u8) !SliceType { | 783 | fn dupeWithSentinel(comptime SliceType: type, allocator: *mem.Allocator, data: []const u8) !SliceType { |
| 784 | const type_info = @typeInfo(SliceType); | 784 | switch (@typeInfo(SliceType)) { |
| 785 | switch (type_info) { | ||
| 786 | .Pointer => |ptr_info| { | 785 | .Pointer => |ptr_info| { |
| 787 | if (ptr_info.sentinel) |sentinel| { | 786 | if (ptr_info.sentinel) |sentinel| { |
| 788 | const slice = try allocator.alloc(u8, data.len + 1); | 787 | const slice = try allocator.alloc(u8, data.len + 1); |
| @@ -857,10 +856,8 @@ pub fn Iterator(comptime Type: type) type { | |||
| 857 | @compileError("options passed to readPointer must have an allocator field"); | 856 | @compileError("options passed to readPointer must have an allocator field"); |
| 858 | } | 857 | } |
| 859 | 858 | ||
| 860 | const type_info = @typeInfo(PointerType); | ||
| 861 | |||
| 862 | var ret: PointerType = undefined; | 859 | var ret: PointerType = undefined; |
| 863 | switch (type_info) { | 860 | switch (@typeInfo(PointerType)) { |
| 864 | .Pointer => |ptr| { | 861 | .Pointer => |ptr| { |
| 865 | switch (ptr.size) { | 862 | switch (ptr.size) { |
| 866 | .One => { | 863 | .One => { |
| @@ -887,14 +884,11 @@ pub fn Iterator(comptime Type: type) type { | |||
| 887 | @compileError("options passed to readOptional must be a struct"); | 884 | @compileError("options passed to readOptional must be a struct"); |
| 888 | } | 885 | } |
| 889 | 886 | ||
| 890 | const i = @intCast(c_int, _i); | ||
| 891 | const type_info = @typeInfo(OptionalType); | ||
| 892 | |||
| 893 | var ret: OptionalType = undefined; | 887 | var ret: OptionalType = undefined; |
| 894 | switch (type_info) { | 888 | switch (@typeInfo(OptionalType)) { |
| 895 | .Optional => |opt| { | 889 | .Optional => |opt| { |
| 896 | // Easy way to know if the column represents a null value. | 890 | // Easy way to know if the column represents a null value. |
| 897 | const value = c.sqlite3_column_value(self.stmt, i); | 891 | const value = c.sqlite3_column_value(self.stmt, @intCast(c_int, _i)); |
| 898 | const datatype = c.sqlite3_value_type(value); | 892 | const datatype = c.sqlite3_value_type(value); |
| 899 | 893 | ||
| 900 | if (datatype == c.SQLITE_NULL) { | 894 | if (datatype == c.SQLITE_NULL) { |