Browse Source

avoid variables captured in closure from becoming boxed by passing them in as arguments.

This is kind of sad...
pull/30/head
Kristoffer 1 year ago
parent
commit
cfdc2a4730
  1. 10
      src/runestone.jl

10
src/runestone.jl

@ -424,7 +424,7 @@ function spaces_in_listlike(ctx::Context, node::Node)
end end
# Helper to compute the new state after a given item # Helper to compute the new state after a given item
function state_after_item(i) function state_after_item(i, last_item_idx, require_trailing_comma)
@assert i <= last_item_idx @assert i <= last_item_idx
if i < last_item_idx if i < last_item_idx
return :expect_comma return :expect_comma
@ -547,7 +547,7 @@ function spaces_in_listlike(ctx::Context, node::Node)
accept_node!(ctx, kid′) accept_node!(ctx, kid′)
end end
# Transition to the next state # Transition to the next state
state = state_after_item(i) state = state_after_item(i, last_item_idx, require_trailing_comma)
end end
elseif state === :expect_comma elseif state === :expect_comma
trailing = i > last_item_idx trailing = i > last_item_idx
@ -711,7 +711,7 @@ function spaces_in_listlike(ctx::Context, node::Node)
# Newline, comment, or whitespace followed by comment # Newline, comment, or whitespace followed by comment
accept_node!(ctx, kid′) accept_node!(ctx, kid′)
any_kid_changed && push!(kids′, kid′) any_kid_changed && push!(kids′, kid′)
state = state_after_item(i) state = state_after_item(i, last_item_idx, require_trailing_comma)
elseif kind(first_leaf(kid′)) === K"Whitespace" elseif kind(first_leaf(kid′)) === K"Whitespace"
ws_node = first_leaf(kid′) ws_node = first_leaf(kid′)
if span(ws_node) == 1 if span(ws_node) == 1
@ -727,7 +727,7 @@ function spaces_in_listlike(ctx::Context, node::Node)
accept_node!(ctx, kid′) accept_node!(ctx, kid′)
push!(kids′, kid′) push!(kids′, kid′)
end end
state = state_after_item(i) state = state_after_item(i, last_item_idx, require_trailing_comma)
else else
# Insert a standalone space kid and then accept the current node # Insert a standalone space kid and then accept the current node
this_kid_changed = true this_kid_changed = true
@ -740,7 +740,7 @@ function spaces_in_listlike(ctx::Context, node::Node)
push!(kids′, kid′) push!(kids′, kid′)
accept_node!(ctx, kid′) accept_node!(ctx, kid′)
# Here we inserted a space and consumed the next item, moving on to comma # Here we inserted a space and consumed the next item, moving on to comma
state = state_after_item(i) state = state_after_item(i, last_item_idx, require_trailing_comma)
end end
end end
else else

Loading…
Cancel
Save