Skip to content

Commit fee6aa5

Browse files
committed
Use a mutable type instead of ref fields
1 parent 04b2323 commit fee6aa5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/JuliaSyntaxHighlighting.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ function paren_type(k::Kind)
132132
end
133133
end
134134

135-
struct ParenDepthCounter
136-
paren::Base.RefValue{UInt}
137-
bracket::Base.RefValue{UInt}
138-
curly::Base.RefValue{UInt}
135+
mutable struct ParenDepthCounter
136+
paren::UInt
137+
bracket::UInt
138+
curly::UInt
139139
end
140140

141141
ParenDepthCounter() =
142-
ParenDepthCounter(Ref(zero(UInt)), Ref(zero(UInt)), Ref(zero(UInt)))
142+
ParenDepthCounter(zero(UInt), zero(UInt), zero(UInt))
143143

144144
struct GreenLineage
145145
node::GreenNode
@@ -305,12 +305,12 @@ function _hl_annotations!(highlights::Vector{Tuple{UnitRange{Int}, Pair{Symbol,
305305
end
306306
elseif JuliaSyntax.is_error(nkind); :julia_error
307307
elseif ((depthchange, ptype) = paren_type(nkind)) |> last != :none
308-
depthref = getfield(pdepths, ptype)[]
308+
depthref = getfield(pdepths, ptype)
309309
pdepth = if depthchange > 0
310-
getfield(pdepths, ptype)[] += depthchange
310+
setfield!(pdepths, ptype, depthref + depthchange)
311311
else
312-
depth0 = getfield(pdepths, ptype)[]
313-
getfield(pdepths, ptype)[] += depthchange
312+
depth0 = getfield(pdepths, ptype)
313+
setfield!(pdepths, ptype, depthref + depthchange)
314314
depth0
315315
end
316316
if pdepth <= 0 && UNMATCHED_DELIMITERS_ENABLED[]

0 commit comments

Comments
 (0)