diff options
author | bptato <nincsnevem662@gmail.com> | 2025-01-12 18:16:49 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-01-12 18:21:15 +0100 |
commit | 7b005123a364660f8ea8d801f84bf7a5f746d654 (patch) | |
tree | 0b3da54e5ea7b44b64ca121849d8670f1ee92da1 /src/utils | |
parent | c3065fad6dcf831b055a6b8d23d47fa3acb1326f (diff) | |
download | chawan-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/utils')
-rw-r--r-- | src/utils/twtstr.nim | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index c674eb7a..fed6a561 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -394,13 +394,13 @@ func parseIntP*(s: openArray[char]): Option[int] = return parseIntImpl[int, uint](s, 10) # https://www.w3.org/TR/css-syntax-3/#convert-string-to-number -func parseFloat64*(s: openArray[char]): float64 = +func parseFloat32*(s: openArray[char]): float32 = var sign = 1f64 var t = 1 var d = 0 - var integer: float64 = 0 - var f: float64 = 0 - var e: float64 = 0 + var integer = 0f32 + var f = 0f32 + var e = 0f32 var i = 0 if i < s.len and s[i] == '-': sign = -1f64 @@ -409,13 +409,13 @@ func parseFloat64*(s: openArray[char]): float64 = inc i while i < s.len and s[i] in AsciiDigit: integer *= 10 - integer += float64(decValue(s[i])) + integer += float32(decValue(s[i])) inc i if i < s.len and s[i] == '.': inc i while i < s.len and s[i] in AsciiDigit: f *= 10 - f += float64(decValue(s[i])) + f += float32(decValue(s[i])) inc i inc d if i < s.len and (s[i] == 'e' or s[i] == 'E'): @@ -427,9 +427,9 @@ func parseFloat64*(s: openArray[char]): float64 = inc i while i < s.len and s[i] in AsciiDigit: e *= 10 - e += float64(decValue(s[i])) + e += float32(decValue(s[i])) inc i - return sign * (integer + f * pow(10, float64(-d))) * pow(10, (float64(t) * e)) + return sign * (integer + f * pow(10, float32(-d))) * pow(10, (float32(t) * e)) const ControlPercentEncodeSet* = Controls + NonAscii const FragmentPercentEncodeSet* = ControlPercentEncodeSet + |