Skip to content

Commit

Permalink
make Base.ANSIIterator have a concrete field (JuliaLang#56088)
Browse files Browse the repository at this point in the history
Avoids the invalidation

```
   backedges: 1: superseding sizeof(s::AbstractString) @ Base strings/basic.jl:177 with MethodInstance for sizeof(::AbstractString) (75 children)
```

shown in
JuliaLang#56080 (comment).

Co-authored-by: KristofferC <[email protected]>
  • Loading branch information
KristofferC and KristofferC authored Oct 11, 2024
1 parent 1438b15 commit 9844d85
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ ncodeunits(c::ANSIDelimiter) = ncodeunits(c.del)
textwidth(::ANSIDelimiter) = 0

# An iterator similar to `pairs(::String)` but whose values are Char or ANSIDelimiter
struct ANSIIterator
captures::RegexMatchIterator
struct ANSIIterator{S}
captures::RegexMatchIterator{S}
end
ANSIIterator(s::AbstractString) = ANSIIterator(eachmatch(ansi_regex, s))

IteratorSize(::Type{ANSIIterator}) = SizeUnknown()
eltype(::Type{ANSIIterator}) = Pair{Int, Union{Char,ANSIDelimiter}}
IteratorSize(::Type{<:ANSIIterator}) = SizeUnknown()
eltype(::Type{<:ANSIIterator}) = Pair{Int, Union{Char,ANSIDelimiter}}
function iterate(I::ANSIIterator, (i, m_st)=(1, iterate(I.captures)))
m_st === nothing && return nothing
m, (j, new_m_st) = m_st
Expand Down

0 comments on commit 9844d85

Please sign in to comment.