• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #38182

15 Aug 2025 03:55AM UTC coverage: 77.87% (-0.4%) from 78.28%
#38182

push

local

web-flow
🤖 [master] Bump the SparseArrays stdlib from 30201ab to bb5ecc0 (#59263)

Stdlib: SparseArrays
URL: https://github.com/JuliaSparse/SparseArrays.jl.git
Stdlib branch: main
Julia branch: master
Old commit: 30201ab
New commit: bb5ecc0
Julia version: 1.13.0-DEV
SparseArrays version: 1.13.0
Bump invoked by: @ViralBShah
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
https://github.com/JuliaSparse/SparseArrays.jl/compare/30201abcb...bb5ecc091

```
$ git log --oneline 30201ab..bb5ecc0
bb5ecc0 fast quadratic form for dense matrix, sparse vectors (#640)
34ece87 Extend 3-arg `dot` to generic `HermOrSym` sparse matrices (#643)
095b685 Exclude unintended complex symmetric sparse matrices from 3-arg `dot` (#642)
8049287 Fix signature for 2-arg matrix-matrix `dot` (#641)
cff971d Make cond(::SparseMatrix, 1 / Inf) discoverable from 2-norm error (#629)
```

Co-authored-by: ViralBShah <744411+ViralBShah@users.noreply.github.com>

48274 of 61993 relevant lines covered (77.87%)

9571166.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.48
/base/idset.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
"""
4
    IdSet{T}([itr])
5
    IdSet()
6

7
`IdSet{T}()` constructs a set (see [`Set`](@ref)) using
8
`===` as equality with values of type `T`.
9

10
In the example below, the values are all `isequal` so they get overwritten in the ordinary `Set`.
11
The `IdSet` compares by `===` and so preserves the 3 different values.
12

13
# Examples
14
```jldoctest; filter = r"\\n\\s*(1|1\\.0|true)"
15
julia> Set(Any[true, 1, 1.0])
16
Set{Any} with 1 element:
17
  1.0
18

19
julia> IdSet{Any}(Any[true, 1, 1.0])
20
IdSet{Any} with 3 elements:
21
  1.0
22
  1
23
  true
24
```
25
"""
26
mutable struct IdSet{K} <: AbstractSet{K}
27
    list::Memory{Any}
28
    idxs::Union{Memory{UInt8}, Memory{UInt16}, Memory{UInt32}}
29
    count::Int
30
    max::Int # n.b. always <= length(list)
31
    IdSet{T}() where {T} = new(Memory{Any}(undef, 0), Memory{UInt8}(undef, 0), 0, 0)
305,857✔
32
    IdSet{T}(s::IdSet{T}) where {T} = new(copy(s.list), copy(s.idxs), s.count, s.max)
×
33
end
34
IdSet{T}(itr) where {T} = union!(IdSet{T}(), itr)
17✔
35
IdSet() = IdSet{Any}()
41✔
36

37
copymutable(s::IdSet) = typeof(s)(s)
×
38
emptymutable(s::IdSet{T}, ::Type{U}=T) where {T,U} = IdSet{U}()
×
39
copy(s::IdSet) = typeof(s)(s)
1,113✔
40

41
haskey(s::IdSet, @nospecialize(key)) = ccall(:jl_idset_peek_bp, Int, (Any, Any, Any), s.list, s.idxs, key) != -1
19,001✔
42
isempty(s::IdSet) = s.count == 0
896,621✔
43
length(s::IdSet)  = s.count
25,350✔
44
in(@nospecialize(x), s::IdSet) = haskey(s, x)
18,645✔
45
function push!(s::IdSet, @nospecialize(x))
36,782✔
46
    idx = ccall(:jl_idset_peek_bp, Int, (Any, Any, Any), s.list, s.idxs, x)
36,782✔
47
    if idx >= 0
36,782✔
48
        s.list[idx + 1] = x
7,622✔
49
    else
50
        if s.max < length(s.list)
29,160✔
51
            idx = s.max
21,332✔
52
            @assert !isassigned(s.list, idx + 1)
21,332✔
53
            s.list[idx + 1] = x
21,332✔
54
            s.max = idx + 1
21,332✔
55
        else
56
            newidx = RefValue{Int}(0)
7,828✔
57
            setfield!(s, :list, ccall(:jl_idset_put_key, Any, (Any, Any, Ptr{Int}), s.list, x, newidx))
7,828✔
58
            idx = newidx[]
7,828✔
59
            s.max = idx < 0 ? -idx : idx + 1
7,828✔
60
        end
61
        @assert s.list[s.max] === x
29,160✔
62
        setfield!(s, :idxs, ccall(:jl_idset_put_idx, Any, (Any, Any, Int), s.list, s.idxs, idx))
29,160✔
63
        s.count += 1
29,160✔
64
    end
65
    s
36,782✔
66
end
67
function _pop!(s::IdSet, @nospecialize(x))
100,328✔
68
    removed = ccall(:jl_idset_pop, Int, (Any, Any, Any), s.list, s.idxs, x)
424,408✔
69
    if removed != -1
424,408✔
70
        s.count -= 1
37✔
71
        while s.max > 0 && !isassigned(s.list, s.max)
60✔
72
            s.max -= 1
23✔
73
        end
23✔
74
    end
75
    removed
182,409✔
76
end
77
pop!(s::IdSet, @nospecialize(x)) = _pop!(s, x) == -1 ? throw(KeyError(x)) : x
×
78
pop!(s::IdSet, @nospecialize(x), @nospecialize(default)) = _pop!(s, x) == -1 ? default : x
×
79
delete!(s::IdSet, @nospecialize(x)) = (_pop!(s, x); s)
324,080✔
80

81
function sizehint!(s::IdSet, newsz::Integer)
82
    # TODO: grow/compact list and perform rehash, if profitable?
83
    # TODO: shrink?
84
    # s.list = resize(s.list, newsz)
85
    # newsz = _tablesz(newsz)
86
    # oldsz = length(s.idxs)
87
    # #grow at least 25%
88
    # if newsz < (oldsz*5)>>2
89
    #     return s
90
    # end
91
    # rehash!(s, newsz)
92
    nothing
16,403✔
93
end
94

95
function _zero!(a::Memory{<:BitInteger})
3✔
96
    t = @_gc_preserve_begin a
3,483✔
97
    p = unsafe_convert(Ptr{Cvoid}, a)
3,483✔
98
    T = eltype(a)
3,483✔
99
    memset(p, 0x0, (sizeof(T) * length(a)) % UInt)
3,483✔
100
    @_gc_preserve_end t
3,483✔
101
    return a
3,483✔
102
end
103

104
function empty!(s::IdSet)
3,483✔
105
    _zero!(s.idxs)
6,966✔
106
    list = s.list
3,483✔
107
    for i = 1:s.max
5,452✔
108
        _unsetindex!(list, i)
4,198✔
109
    end
6,427✔
110
    s.count = 0
3,483✔
111
    s.max = 0
3,483✔
112
    s
3,483✔
113
end
114

115
filter!(f, d::IdSet) = unsafe_filter!(f, d)
×
116

117
function iterate(s::IdSet{S}, state=0) where {S}
1,166✔
118
    while true
60,609✔
119
        state += 1
31,734✔
120
        state > s.max && return nothing
31,734✔
121
        isassigned(s.list, state) && return s.list[state]::S, state
8,889✔
122
    end
14✔
123
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc