Skip to content

Commit

Permalink
Serialization: fix a handful of implicit return mistakes
Browse files Browse the repository at this point in the history
This would have caused us to perform a number of unncessary allocations and method specializations
  • Loading branch information
vtjnash committed Jun 11, 2018
1 parent 3bcb571 commit 624dbbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions base/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function __init__()
catch ex
Base.showerror_nostdio(ex, "WARNING: Error during initialization of module MPFR")
end
nothing
end

const ROUNDING_MODE = RefValue{Cint}(0)
Expand Down
11 changes: 9 additions & 2 deletions stdlib/Serialization/src/Serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,16 @@ const REF_OBJECT_TAG = Int32(o0+13)
const FULL_GLOBALREF_TAG = Int32(o0+14)
const HEADER_TAG = Int32(o0+15)

writetag(s::IO, tag) = write(s, UInt8(tag))
writetag(s::IO, tag) = (write(s, UInt8(tag)); nothing)

function write_as_tag(s::IO, tag)
tag < VALUE_TAGS && write(s, UInt8(0))
write(s, UInt8(tag))
nothing
end

# cycle handling
function serialize_cycle(s::AbstractSerializer, x)
function serialize_cycle(s::AbstractSerializer, @nospecialize(x))
offs = get(s.table, x, -1)::Int
if offs != -1
if offs <= typemax(UInt16)
Expand Down Expand Up @@ -225,6 +226,7 @@ function serialize(s::AbstractSerializer, x::Symbol)
write(s.io, Int32(len))
end
unsafe_write(s.io, pname, len)
nothing
end

function serialize_array_data(s::IO, a)
Expand Down Expand Up @@ -290,6 +292,7 @@ function serialize(s::AbstractSerializer, ss::String)
write(s.io, Int64(len))
end
write(s.io, ss)
nothing
end

function serialize(s::AbstractSerializer, ss::SubString{String})
Expand Down Expand Up @@ -546,6 +549,7 @@ function serialize_type_data(s, t::DataType)
end
end
end
nothing
end

function serialize(s::AbstractSerializer, t::DataType)
Expand Down Expand Up @@ -575,6 +579,7 @@ function serialize(s::AbstractSerializer, n::Int32)
writetag(s.io, INT32_TAG)
write(s.io, n)
end
nothing
end

function serialize(s::AbstractSerializer, n::Int64)
Expand All @@ -587,6 +592,7 @@ function serialize(s::AbstractSerializer, n::Int64)
writetag(s.io, INT64_TAG)
write(s.io, n)
end
nothing
end

serialize(s::AbstractSerializer, ::Type{Bottom}) = write_as_tag(s.io, BOTTOM_TAG)
Expand Down Expand Up @@ -636,6 +642,7 @@ function serialize_any(s::AbstractSerializer, @nospecialize(x))
end
end
end
nothing
end

"""
Expand Down

0 comments on commit 624dbbe

Please sign in to comment.