ludic.ui: string matching compares in place - at_alias, lk_in, colours and every s[a..b] == p made a string per position tried, per rule, per element, per frame (a benchmark page: ~3 MB -> 256 KB a frame)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8808dda605
commit
83200a453b
17 changed files with 84 additions and 50 deletions
|
|
@ -4,14 +4,14 @@
|
|||
function el_unit(ui_st: UiState, s: string) -> float {
|
||||
let f = el_num(s)
|
||||
let n = len(s)
|
||||
if n > 3 and s[n - 3..n] == "rem" { return f * el_px(ui_st, 16.0) }
|
||||
if n > 2 and s[n - 2..n] == "em" {
|
||||
if n > 3 and sat(s, n - 3, "rem") { return f * el_px(ui_st, 16.0) }
|
||||
if n > 2 and sat(s, n - 2, "em") {
|
||||
if ui_st.el_cur == null { return f * el_px(ui_st, 16.0) }
|
||||
if ui_st.el_key == "size" and ui_st.el_cur.parent != null { return f * cs_fs(ui_st, ui_st.el_cur.parent) }
|
||||
return f * cs_fs(ui_st, ui_st.el_cur)
|
||||
}
|
||||
if n > 2 and s[n - 2..n] == "vw" { return f * ui_st.ly_vp_w / 100.0 }
|
||||
if n > 2 and s[n - 2..n] == "vh" { return f * ui_st.ly_vp_h / 100.0 }
|
||||
if n > 2 and sat(s, n - 2, "vw") { return f * ui_st.ly_vp_w / 100.0 }
|
||||
if n > 2 and sat(s, n - 2, "vh") { return f * ui_st.ly_vp_h / 100.0 }
|
||||
return el_px(ui_st, f)
|
||||
}
|
||||
# the font size an element has so far in its cascade (its own, else its parent's)
|
||||
|
|
@ -55,7 +55,7 @@ function cs_vars_in(ui_st: mut UiState, n: UiNode, v: Val) -> Val {
|
|||
var found = false
|
||||
var i = 0
|
||||
while i + 4 <= len(s) {
|
||||
if s[i..i + 4] == "var(" {
|
||||
if sat(s, i, "var(") {
|
||||
found = true
|
||||
var j = i + 4
|
||||
var depth = 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue