From 7b005123a364660f8ea8d801f84bf7a5f746d654 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 12 Jan 2025 18:16:49 +0100 Subject: cssvalues: reduce CSSValues size * switch from float64 -> float32; other browsers use 32-bit floats too * specify integer size as 32-bit * use NetworkBitmap for background-image value (currently just an invalid dummy value) * remove "none" property & value types CSSValue's payload is always one word (plus another for the type tag). CSSValues keeps its size, but no longer has to heap-alloc + refcount word-sized CSSValues. (On 32-bit systems, CSSValues might actually be larger than before, but I expect it's still a net benefit with the removal of refcounting and the switch to 32-bit floats.) --- src/html/dom.nim | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/html') diff --git a/src/html/dom.nim b/src/html/dom.nim index 17f32890..b06a1d04 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -3871,13 +3871,9 @@ proc getComputedStyle*(element: Element): CSSStyleDeclaration = if element.cachedComputedStyle == nil: var s = "" for p in CSSPropertyType: - if p != cptNone: - s &= $p & ':' - if p.isBit: - s &= element.computed.bits[p].serialize(valueType(p)) - else: - s &= element.computed.objs[p].serialize() - s &= ';' + s &= $p & ':' + s &= element.computed.serialize(p) + s &= ';' element.cachedComputedStyle = newCSSStyleDeclaration(element, move(s)) element.cachedComputedStyle.computed = true element.cachedComputedStyle.readonly = true -- cgit