| ... | ... | @@ -14,16 +14,13 @@ pub const Codepoints = union(enum) { |
| 14 | 14 | |
| 15 | 15 | pub const ENTITIES = @import("entities.zig").ENTITIES; |
| 16 | 16 | |
| 17 | | fn order(_: void, lhs: Entity, rhs: Entity) std.math.Order { |
| 17 | fn compare(lhs: Entity, rhs: Entity) std.math.Order { |
| 18 | 18 | return std.mem.order(u8, lhs.entity, rhs.entity); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | pub fn lookup(entity: []const u8) ?Entity { |
| 22 | | const maybe_index = std.sort.binarySearch(Entity, Entity{ |
| 23 | | .entity = entity, |
| 24 | | .codepoints = .{ .Single = 0 }, |
| 25 | | .characters = "", |
| 26 | | }, ENTITIES[0..], {}, order); |
| 22 | const context: Entity = .{ .entity = entity, .codepoints = .{ .Single = 0 }, .characters = "" }; |
| 23 | const maybe_index = std.sort.binarySearch(Entity, &ENTITIES, context, compare); |
| 27 | 24 | |
| 28 | 25 | if (maybe_index) |index| { |
| 29 | 26 | return ENTITIES[index]; |