adjust emojis

This commit is contained in:
Emil Lerch 2025-12-18 16:39:01 -08:00
parent 5352457032
commit c99551e35c
Signed by: lobo
GPG key ID: A7B62D657EF764F8
2 changed files with 14 additions and 14 deletions

20
src/cache/Lru.zig vendored
View file

@ -1,6 +1,6 @@
const std = @import("std");
const LRU = @This();
const Lru = @This();
allocator: std.mem.Allocator,
map: std.StringHashMap(Entry),
@ -12,15 +12,15 @@ const Entry = struct {
access_count: u64,
};
pub fn init(allocator: std.mem.Allocator, max_entries: usize) !LRU {
return LRU{
pub fn init(allocator: std.mem.Allocator, max_entries: usize) !Lru {
return .{
.allocator = allocator,
.map = std.StringHashMap(Entry).init(allocator),
.max_entries = max_entries,
};
}
pub fn get(self: *LRU, key: []const u8) ?[]const u8 {
pub fn get(self: *Lru, key: []const u8) ?[]const u8 {
var entry = self.map.getPtr(key) orelse return null;
const now = std.time.milliTimestamp();
@ -33,7 +33,7 @@ pub fn get(self: *LRU, key: []const u8) ?[]const u8 {
return entry.value;
}
pub fn put(self: *LRU, key: []const u8, value: []const u8, expires: i64) !void {
pub fn put(self: *Lru, key: []const u8, value: []const u8, expires: i64) !void {
if (self.map.get(key)) |old_entry| {
self.allocator.free(old_entry.value);
_ = self.map.remove(key);
@ -53,7 +53,7 @@ pub fn put(self: *LRU, key: []const u8, value: []const u8, expires: i64) !void {
});
}
fn evictOldest(self: *LRU) void {
fn evictOldest(self: *Lru) void {
var oldest_key: ?[]const u8 = null;
var oldest_access: u64 = std.math.maxInt(u64);
@ -70,14 +70,14 @@ fn evictOldest(self: *LRU) void {
}
}
fn remove(self: *LRU, key: []const u8) void {
fn remove(self: *Lru, key: []const u8) void {
if (self.map.fetchRemove(key)) |kv| {
self.allocator.free(kv.value.value);
self.allocator.free(kv.key);
}
}
pub fn deinit(self: *LRU) void {
pub fn deinit(self: *Lru) void {
var it = self.map.iterator();
while (it.next()) |entry| {
self.allocator.free(entry.value_ptr.value);
@ -87,7 +87,7 @@ pub fn deinit(self: *LRU) void {
}
test "LRU basic operations" {
var lru = try LRU.init(std.testing.allocator, 3);
var lru = try Lru.init(std.testing.allocator, 3);
defer lru.deinit();
try lru.put("key1", "value1", 9999999999999);
@ -95,7 +95,7 @@ test "LRU basic operations" {
}
test "LRU eviction" {
var lru = try LRU.init(std.testing.allocator, 2);
var lru = try Lru.init(std.testing.allocator, 2);
defer lru.deinit();
try lru.put("key1", "value1", 9999999999999);

View file

@ -121,12 +121,12 @@ fn getConditionEmoji(code: types.WeatherCode) []const u8 {
800 => "☀️", // Clear
801, 802 => "⛅️", // Few/scattered clouds
803, 804 => "☁️", // Broken/overcast clouds
701, 741 => "🌫", // Mist/fog
701, 741 => "🌁", // Mist/fog (alternatively, maybe 🌫 or 🌫 is better)
300...321 => "🌦", // Drizzle
500...531 => "🌧", // Rain
200...232 => "", // Thunderstorm
500...531 => "🌧", // Rain
200...232 => "", // Thunderstorm
611...616 => "❄️", // Sleet/freezing (check before snow)
600...610, 617...622 => "🌨", // Snow
600...610, 617...622 => "🌨", // Snow
else => "🌡️",
};
}