Skip to content

Commit 84dd768

Browse files
authored
Merge branch 'master' into interactive-utils-functors
2 parents 76f030c + 9fc33b9 commit 84dd768

File tree

7 files changed

+68
-23
lines changed

7 files changed

+68
-23
lines changed

Compiler/src/ssair/show.jl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,30 @@ function print_stmt(io::IO, idx::Int, @nospecialize(stmt), code::Union{IRCode,Co
105105
printstyled(io, "dynamic invoke "; color = :yellow)
106106
abi = (ci::Core.MethodInstance).specTypes
107107
end
108-
show_unquoted(io, stmt.args[2], indent)
109-
print(io, "(")
110108
# XXX: this is wrong if `sig` is not a concretetype method
111109
# more correct would be to use `fieldtype(sig, i)`, but that would obscure / discard Varargs information in show
112110
sig = abi == Tuple ? Core.svec() : Base.unwrap_unionall(abi).parameters::Core.SimpleVector
111+
f = stmt.args[2]
112+
ft = maybe_argextype(f, code, sptypes)
113+
114+
# We can elide the type for arg0 if it...
115+
skip_ftype = (length(sig) == 0) # doesn't exist...
116+
skip_ftype = skip_ftype || (
117+
# ... or, f prints as a user-accessible value...
118+
(f isa GlobalRef) &&
119+
# ... and matches the value of the singleton type of the invoked MethodInstance
120+
(singleton_type(ft) === singleton_type(sig[1]) !== nothing)
121+
)
122+
if skip_ftype
123+
show_unquoted(io, f, indent)
124+
else
125+
print(io, "(")
126+
show_unquoted(io, f, indent)
127+
print(io, "::", sig[1], ")")
128+
end
129+
130+
# Print the remaining arguments (with type annotations from the invoked MethodInstance)
131+
print(io, "(")
113132
print_arg(i) = sprint(; context=io) do io
114133
show_unquoted(io, stmt.args[i], indent)
115134
if (i - 1) <= length(sig)

base/combinatorics.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,12 @@ end
184184
"""
185185
permute!(v, p)
186186
187-
Permute vector `v` in-place, according to permutation `p`. No checking is done
188-
to verify that `p` is a permutation.
187+
Permute vector `v` according to permutation `p`, storing the result back into `v`.
188+
No checking is done to verify that `p` is a permutation.
189189
190190
To return a new permutation, use `v[p]`. This is generally faster than `permute!(v, p)`;
191191
it is even faster to write into a pre-allocated output array with `u .= @view v[p]`.
192-
(Even though `permute!` overwrites `v` in-place, it internally requires some allocation
193-
to keep track of which elements have been moved.)
192+
(Even though `permute!` overwrites `v` in-place, it internally requires some allocation.)
194193
195194
$(_DOCS_ALIASING_WARNING)
196195

base/iterators.jl

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,20 +1239,48 @@ flatten_length(f, T) = throw(ArgumentError(
12391239
length(f::Flatten{I}) where {I} = flatten_length(f, eltype(I))
12401240
length(f::Flatten{Tuple{}}) = 0
12411241

1242-
@propagate_inbounds function iterate(f::Flatten, state=())
1243-
if state !== ()
1244-
y = iterate(tail(state)...)
1245-
y !== nothing && return (y[1], (state[1], state[2], y[2]))
1242+
@propagate_inbounds function iterate(fl::Flatten)
1243+
it_result = iterate(fl.it)
1244+
it_result === nothing && return nothing
1245+
1246+
inner_iterator, next_outer_state = it_result
1247+
inner_it_result = iterate(inner_iterator)
1248+
1249+
while inner_it_result === nothing
1250+
it_result = iterate(fl.it, next_outer_state)
1251+
it_result === nothing && return nothing
1252+
1253+
inner_iterator, next_outer_state = it_result
1254+
inner_it_result = iterate(inner_iterator)
12461255
end
1247-
x = (state === () ? iterate(f.it) : iterate(f.it, state[1]))
1248-
x === nothing && return nothing
1249-
y = iterate(x[1])
1250-
while y === nothing
1251-
x = iterate(f.it, x[2])
1252-
x === nothing && return nothing
1253-
y = iterate(x[1])
1256+
1257+
item, next_inner_state = inner_it_result
1258+
return item, (next_outer_state, inner_iterator, next_inner_state)
1259+
end
1260+
1261+
@propagate_inbounds function iterate(fl::Flatten, state)
1262+
next_outer_state, inner_iterator, next_inner_state = state
1263+
1264+
# try to advance the inner iterator
1265+
inner_it_result = iterate(inner_iterator, next_inner_state)
1266+
if inner_it_result !== nothing
1267+
item, next_inner_state = inner_it_result
1268+
return item, (next_outer_state, inner_iterator, next_inner_state)
1269+
end
1270+
1271+
# advance the outer iterator
1272+
while true
1273+
outer_it_result = iterate(fl.it, next_outer_state)
1274+
outer_it_result === nothing && return nothing
1275+
1276+
inner_iterator, next_outer_state = outer_it_result
1277+
inner_it_result = iterate(inner_iterator)
1278+
1279+
if inner_it_result !== nothing
1280+
item, next_inner_state = inner_it_result
1281+
return item, (next_outer_state, inner_iterator, next_inner_state)
1282+
end
12541283
end
1255-
return y[1], (x[2], x[1], y[2])
12561284
end
12571285

12581286
reverse(f::Flatten) = Flatten(reverse(itr) for itr in reverse(f.it))

doc/src/manual/functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ julia> function hypot(x, y)
178178
return x*sqrt(1 + r*r)
179179
end
180180
if y == 0
181-
return x
181+
return float(x)
182182
end
183183
r = x/y
184184
return y*sqrt(1 + r*r)

doc/src/manual/profile.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,7 @@ Passing `sample_rate=1.0` will make it record everything (which is slow);
562562

563563
Since Julia 1.11, all allocations should have a type reported.
564564

565-
For more details on how to use this tool, please see the following talk from JuliaCon 2022:
566-
https://www.youtube.com/watch?v=BFvpwC8hEWQ
565+
For more details on how to use this tool, please see [the talk from JuliaCon 2022](https://www.youtube.com/watch?v=BFvpwC8hEWQ).
567566

568567
##### Allocation Profiler Example
569568

stdlib/Markdown/src/GitHub/table.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
mutable struct Table
3+
mutable struct Table <: MarkdownElement
44
rows::Vector{Vector{Any}}
55
align::Vector{Symbol}
66
end

stdlib/Markdown/src/IPython/IPython.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
mutable struct LaTeX
3+
mutable struct LaTeX <: MarkdownElement
44
formula::String
55
end
66

0 commit comments

Comments
 (0)