Skip to content

Commit

Permalink
Use maximum(itr; init=default)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Jun 23, 2020
1 parent 1bf6b12 commit e2aee5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,8 @@ function set_maximum_version_registry!(ctx::Context, pkg::PackageSpec)
pathvers = keys(load_versions(ctx, path; include_yanked=false))
union!(pkgversions, pathvers)
end
if length(pkgversions) == 0
pkg.version = VersionNumber(0)
else
max_version = maximum(pkgversions)
pkg.version = VersionNumber(max_version.major, max_version.minor, max_version.patch, max_version.prerelease, ("",))
end
max_version = maximum(pkgversions; init=VersionNumber(0))
pkg.version = VersionNumber(max_version.major, max_version.minor, max_version.patch, max_version.prerelease, ("",))
end

function load_deps(ctx::Context, pkg::PackageSpec)::Dict{String,UUID}
Expand Down Expand Up @@ -691,7 +687,7 @@ function download_source(ctx::Context, pkgs::Vector{PackageSpec},
end

widths = [textwidth(pkg.name) for (pkg, _) in pkgs_to_install]
max_name = length(widths) == 0 ? 0 : maximum(widths)
max_name = maximum(widths; init=0)

########################################
# Install from archives asynchronously #
Expand Down Expand Up @@ -900,7 +896,7 @@ function build_versions(ctx::Context, uuids::Vector{UUID}; might_need_to_resolve
# toposort builds by dependencies
order = dependency_order_uuids(ctx, map(first, builds))
sort!(builds, by = build -> order[first(build)])
max_name = isempty(builds) ? 0 : maximum(textwidth.([build[2] for build in builds]))
max_name = maximum(build->textwidth(build[2]), builds; init=0)
# build each package versions in a child process
for (uuid, name, source_path, version) in builds
pkg = PackageSpec(;uuid=uuid, name=name, version=version)
Expand Down
2 changes: 1 addition & 1 deletion src/Resolve/graphtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ end
function showlogjournal(io::IO, rlog::ResolveLog)
journal = rlog.journal
id(p) = p == UUID0 ? "[global event]" : pkgID(p, rlog)
padding = maximum(length(id(p)) for (p,_) in journal)
padding = maximum(length(id(p)) for (p,_) in journal; init=0)
for (p,msg) in journal
println(io, ' ', rpad(id(p), padding), ": ", msg)
end
Expand Down

0 comments on commit e2aee5c

Please sign in to comment.