Skip to content

Commit

Permalink
Merge pull request #27 from ghivert/fix/remove-stack-overflow-fold-right
Browse files Browse the repository at this point in the history
Remove `fold_right` functions to avoid stack overflows on JS
  • Loading branch information
ghivert authored Sep 17, 2024
2 parents c4814eb + 9b3d4ac commit 47ccbf0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sketch/src/sketch/internals/style.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn compute_properties(
indent: Int,
) -> #(Cache, ComputedProperties) {
let init = init_computed_properties(indent)
use #(cache, acc), prop <- list.fold_right(properties, #(cache, init))
use #(cache, acc), prop <- list.fold(list.reverse(properties), #(cache, init))
case prop {
NoStyle -> #(cache, acc)
Property(_, _, _) -> #(cache, handle_property(acc, prop))
Expand Down
2 changes: 1 addition & 1 deletion sketch_lustre/src/sketch/lustre/element.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub fn unstyled(cache: Cache, element: Element(msg)) {
}

fn unstyled_children(cache, children) {
list.fold_right(children, #(cache, []), fn(acc, child) {
list.fold(list.reverse(children), #(cache, []), fn(acc, child) {
let #(cache, children) = acc
let #(cache, child) = unstyled(cache, child)
#(cache, [child, ..children])
Expand Down

0 comments on commit 47ccbf0

Please sign in to comment.