| ... | ... | @@ -98,6 +98,21 @@ pub const CacheHash = struct { |
| 98 | 98 | switch (@typeInfo(val_type)) { |
| 99 | 99 | .Int => self.addInt(val), |
| 100 | 100 | .Bool => self.addBool(val), |
| 101 | .Array => |array_info| if (array_info.child == u8) { |
| 102 | self.addSlice(val[0..]); |
| 103 | } else { |
| 104 | @compileError("Unsupported array type"); |
| 105 | }, |
| 106 | .Pointer => |ptr_info| switch (ptr_info.size) { |
| 107 | .Slice => if (ptr_info.child == u8) { |
| 108 | self.addSlice(val); |
| 109 | }, |
| 110 | .One => self.add(val.*), |
| 111 | else => { |
| 112 | @compileLog("Pointer type: ", ptr_info.size, ptr_info.child); |
| 113 | @compileError("Unsupported pointer type"); |
| 114 | }, |
| 115 | }, |
| 101 | 116 | else => @compileError("Unsupported type"), |
| 102 | 117 | } |
| 103 | 118 | } |
| ... | ... | @@ -328,7 +343,7 @@ test "cache file and the recall it" { |
| 328 | 343 | |
| 329 | 344 | ch.add(true); |
| 330 | 345 | ch.add(@as(u16, 1234)); |
| 331 | | ch.addSlice("1234"); |
| 346 | ch.add("1234"); |
| 332 | 347 | try ch.cache_file("test.txt"); |
| 333 | 348 | |
| 334 | 349 | // There should be nothing in the cache |
| ... | ... | @@ -342,7 +357,7 @@ test "cache file and the recall it" { |
| 342 | 357 | |
| 343 | 358 | ch.add(true); |
| 344 | 359 | ch.add(@as(u16, 1234)); |
| 345 | | ch.addSlice("1234"); |
| 360 | ch.add("1234"); |
| 346 | 361 | try ch.cache_file("test.txt"); |
| 347 | 362 | |
| 348 | 363 | // Cache hit! We just "built" the same file |