don't allocate new SubtleCrypto for each access

This commit is contained in:
Halil Durak
2026-01-15 19:08:56 +03:00
parent 0549e07a90
commit 4b4bc1a4d3

View File

@@ -24,7 +24,7 @@ const Page = @import("../Page.zig");
const SubtleCrypto = @import("SubtleCrypto.zig"); const SubtleCrypto = @import("SubtleCrypto.zig");
const Crypto = @This(); const Crypto = @This();
_pad: bool = false, _subtle: SubtleCrypto = .{},
pub const init: Crypto = .{}; pub const init: Crypto = .{};
@@ -46,9 +46,8 @@ pub fn randomUUID(_: *const Crypto) ![36]u8 {
return hex; return hex;
} }
pub fn getSubtle(self: *const Crypto, page: *Page) !*SubtleCrypto { pub fn getSubtle(self: *Crypto) *SubtleCrypto {
_ = self; return &self._subtle;
return page._factory.create(SubtleCrypto{});
} }
const RandomValues = union(enum) { const RandomValues = union(enum) {