stack allocate the cache key for weather

This commit is contained in:
Emil Lerch 2026-01-09 11:59:35 -08:00
parent f936422b07
commit 50e493aad5
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -23,8 +23,8 @@ pub const VTable = struct {
pub fn fetch(self: WeatherProvider, allocator: std.mem.Allocator, coords: Coordinates) !types.WeatherData {
// Generate cache key from coordinates
const cache_key = try std.fmt.allocPrint(allocator, "{d:.4},{d:.4}", .{ coords.latitude, coords.longitude });
defer allocator.free(cache_key);
var buf: [256]u8 = undefined;
const cache_key = try std.fmt.bufPrint(&buf, "{d:.4},{d:.4}", .{ coords.latitude, coords.longitude });
// Check cache first
if (self.cache.get(cache_key)) |cached_raw|