Skip to content

Commit fa84d91

Browse files
authored
Merge branch 'master' into partially_work_around_issue_42372
2 parents 7536d40 + a776445 commit fa84d91

File tree

7 files changed

+44
-9
lines changed

7 files changed

+44
-9
lines changed

base/abstractset.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ intersect!(s::AbstractSet, itr) =
201201
setdiff(s, itrs...)
202202
203203
Construct the set of elements in `s` but not in any of the iterables in `itrs`.
204-
Maintain order with arrays.
204+
Maintain order with arrays. The result will have the same element type as `s`.
205205
206206
See also [`setdiff!`](@ref), [`union`](@ref) and [`intersect`](@ref).
207207
@@ -211,6 +211,10 @@ julia> setdiff([1,2,3], [3,4,5])
211211
2-element Vector{Int64}:
212212
1
213213
2
214+
215+
julia> setdiff([1,2,3], [1.0, 2.0])
216+
1-element Vector{Int64}:
217+
3
214218
```
215219
"""
216220
setdiff(s::AbstractSet, itrs...) = setdiff!(copymutable(s), itrs...)

base/array.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,14 +3133,17 @@ setdiff!( v::AbstractVector, itrs...) = _shrink!(setdiff!, v, itrs)
31333133

31343134
vectorfilter(T::Type, f, v) = T[x for x in v if f(x)]
31353135

3136-
function _shrink(shrinker!::F, itr, itrs) where F
3136+
function intersect(itr, itrs...)
31373137
T = promote_eltype(itr, itrs...)
3138-
keep = shrinker!(Set{T}(itr), itrs...)
3138+
keep = intersect!(Set{T}(itr), itrs...)
31393139
vectorfilter(T, _shrink_filter!(keep), itr)
31403140
end
31413141

3142-
intersect(itr, itrs...) = _shrink(intersect!, itr, itrs)
3143-
setdiff( itr, itrs...) = _shrink(setdiff!, itr, itrs)
3142+
function setdiff(itr, itrs...)
3143+
T = eltype(itr)
3144+
keep = setdiff!(Set{T}(itr), itrs...)
3145+
vectorfilter(T, _shrink_filter!(keep), itr)
3146+
end
31443147

31453148
function intersect(v::AbstractVector, r::AbstractRange)
31463149
T = promote_eltype(v, r)

src/signal-handling.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,11 @@ static void jl_check_profile_autostop(void)
428428
if (profile_show_peek_cond_loc != NULL && profile_autostop_time != -1.0 && jl_hrtime() > profile_autostop_time) {
429429
profile_autostop_time = -1.0;
430430
jl_profile_stop_timer();
431+
// Disable trace compilation when profile collection ends
432+
jl_force_trace_compile_timing_disable();
431433
jl_safe_printf("\n==============================================================\n");
432-
jl_safe_printf("Profile collected. A report will print at the next yield point\n");
434+
jl_safe_printf("Profile collected. A report will print at the next yield point.\n");
435+
jl_safe_printf("Disabling --trace-compile\n");
433436
jl_safe_printf("==============================================================\n\n");
434437
JL_LOCK_NOGC(&profile_show_peek_cond_lock);
435438
if (profile_show_peek_cond_loc != NULL)

src/signals-unix.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,8 @@ static void kqueue_signal(int *sigqueue, struct kevent *ev, int sig)
823823
void trigger_profile_peek(void)
824824
{
825825
jl_safe_printf("\n======================================================================================\n");
826-
jl_safe_printf("Information request received. A stacktrace will print followed by a %.1f second profile\n", profile_peek_duration);
826+
jl_safe_printf("Information request received. A stacktrace will print followed by a %.1f second profile.\n", profile_peek_duration);
827+
jl_safe_printf("--trace-compile is enabled during profile collection.\n");
827828
jl_safe_printf("======================================================================================\n");
828829
if (profile_bt_size_max == 0) {
829830
// If the buffer hasn't been initialized, initialize with default size
@@ -1113,6 +1114,9 @@ static void *signal_listener(void *arg)
11131114
for (i = 0; i < signal_bt_size; i += jl_bt_entry_size(signal_bt_data + i)) {
11141115
jl_print_bt_entry_codeloc(signal_bt_data + i);
11151116
}
1117+
jl_safe_printf("\n");
1118+
// Enable trace compilation to stderr with timing during profile collection
1119+
jl_force_trace_compile_timing_enable();
11161120
}
11171121
}
11181122
return NULL;

stdlib/UUIDs/src/UUIDs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ function _build_uuid1(rng::AbstractRNG, timestamp::UInt64)
7474
# mask off clock sequence and node
7575
u &= 0x00000000000000003fffffffffffffff
7676

77-
# set the unicast/multicast bit and version
78-
u |= 0x00000000000010000000010000000000
77+
# set the version, variant, and unicast/multicast bit
78+
u |= 0x00000000000010008000010000000000
7979

8080
ts_low = timestamp & typemax(UInt32)
8181
ts_mid = (timestamp >> 32) & typemax(UInt16)

stdlib/UUIDs/test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ u7 = uuid7()
4242
@test uuid_version(u7) == 7
4343
end
4444

45+
@testset "Extraction of variant bits" begin
46+
# RFC 4122, section 4.1.1
47+
uuid_variant(u::UUID) = Int((u.value >> 62) & 0x3)
48+
@test uuid_variant(u1) == 2
49+
@test uuid_variant(u4) == 2
50+
@test uuid_variant(u5) == 2
51+
@test uuid_variant(u7) == 2
52+
end
53+
4554
@testset "Parsing from string" begin
4655
@test u1 == UUID(string(u1)) == UUID(GenericString(string(u1)))
4756
@test u4 == UUID(string(u4)) == UUID(GenericString(string(u4)))

test/arrayops.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,18 @@ end
12461246
@test setdiff((1, 2), (3, 2)) == [1]
12471247
@test symdiff((1, 2), (3, 2)) == [1, 3]
12481248
end
1249+
1250+
@testset "setdiff preserves element type of first argument" begin
1251+
@test setdiff([1, 2, 3], [1.0, 2.0]) isa Vector{Int}
1252+
@test setdiff([1.0, 2.0, 3.0], [1, 2]) isa Vector{Float64}
1253+
@test setdiff(['a', 'b', 'c'], [98]) isa Vector{Char}
1254+
@test setdiff([1, 2], [1.0, 2.0]) isa Vector{Int}
1255+
end
1256+
@testset "intersect promotes element types of arguments" begin
1257+
@test intersect([1, 2, 3], [1.0, 2.0]) isa Vector{Float64}
1258+
@test intersect([1.0, 2.0, 3.0], [1, 2]) isa Vector{Float64}
1259+
@test intersect(['a', 'b', 'c'], Int[]) isa Vector{Any}
1260+
end
12491261
end
12501262

12511263
@testset "mapslices" begin

0 commit comments

Comments
 (0)