aboutsummaryrefslogtreecommitdiffstats
path: root/src/css/cssparser.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-01-12 18:16:49 +0100
committerbptato <nincsnevem662@gmail.com>2025-01-12 18:21:15 +0100
commit7b005123a364660f8ea8d801f84bf7a5f746d654 (patch)
tree0b3da54e5ea7b44b64ca121849d8670f1ee92da1 /src/css/cssparser.nim
parentc3065fad6dcf831b055a6b8d23d47fa3acb1326f (diff)
downloadchawan-7b005123a364660f8ea8d801f84bf7a5f746d654.tar.gz
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.)
Diffstat (limited to 'src/css/cssparser.nim')
-rw-r--r--src/css/cssparser.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/css/cssparser.nim b/src/css/cssparser.nim
index e71a9286..7e2f6004 100644
--- a/src/css/cssparser.nim
+++ b/src/css/cssparser.nim
@@ -33,7 +33,7 @@ type
of cttDelim:
cvalue*: char
of cttNumber, cttINumber, cttPercentage, cttDimension, cttIDimension:
- nvalue*: float64
+ nvalue*: float32
unit*: string
else: discard
@@ -263,7 +263,7 @@ proc consumeIdentSequence(state: var CSSTokenizerState): string =
return s
proc consumeNumber(state: var CSSTokenizerState):
- tuple[isInt: bool; val: float64] =
+ tuple[isInt: bool; val: float32] =
var isInt = true
var repr = ""
if state.has() and state.peek() in {'+', '-'}:
@@ -289,7 +289,7 @@ proc consumeNumber(state: var CSSTokenizerState):
isInt = false
while state.has() and state.peek() in AsciiDigit:
repr &= state.consume()
- let val = parseFloat64(repr)
+ let val = parseFloat32(repr)
return (isInt, val)
proc consumeNumericToken(state: var CSSTokenizerState): CSSToken =