Browse Source

perf2

fe/perf
Fredrik Ekre 1 year ago
parent
commit
b0c6fc511b
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 2
      src/Runic.jl
  2. 5
      src/chisels.jl

2
src/Runic.jl

@ -146,6 +146,7 @@ mutable struct Context @@ -146,6 +146,7 @@ mutable struct Context
next_sibling::Union{Node, Nothing}
# parent::Union{Node, Nothing}
lineage_kinds::Vector{JuliaSyntax.Kind}
tmp_buf::IOBuffer
end
function Context(
@ -178,6 +179,7 @@ function Context( @@ -178,6 +179,7 @@ function Context(
return Context(
src_str, src_tree, src_io, fmt_io, fmt_tree, quiet, verbose, assert, debug, check,
diff, filemode, call_depth, indent_level, prev_sibling, next_sibling, lineage_kinds,
IOBuffer(),
)
end

5
src/chisels.jl

@ -557,6 +557,8 @@ end @@ -557,6 +557,8 @@ end
# Utilities for IOBuffer #
##########################
const backup_buffer = IOBuffer()
# Replace bytes for a node at the current position in the IOBuffer. `size` is the current
# window for the node, i.e. the number of bytes until the next node starts. If `size` is
# smaller or larger than the length of `bytes` this method will shift the bytes for
@ -568,7 +570,8 @@ function replace_bytes!(io::IOBuffer, bytes::Union{String, AbstractVector{UInt8} @@ -568,7 +570,8 @@ function replace_bytes!(io::IOBuffer, bytes::Union{String, AbstractVector{UInt8}
nw = write(io, bytes)
@assert nb == nw
else
backup = IOBuffer() # TODO: global const (with lock)?
# backup = IOBuffer() # TODO: global const (with lock)?
backup = truncate(backup_buffer, 0)
seek(io, pos + size)
@assert position(io) == pos + size
nb_written_to_backup = write(backup, io)

Loading…
Cancel
Save