From 47c26dc4cc30b8274ed6ebbb1cfb171430097de6 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 20 Jan 2016 12:07:33 -0500 Subject: [PATCH] forcably inline the byte-write method for IOBuffer, since this tends to end up in the hot-path --- base/iobuffer.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/iobuffer.jl b/base/iobuffer.jl index 1434e2fab5d767..acb91077b00f77 100644 --- a/base/iobuffer.jl +++ b/base/iobuffer.jl @@ -171,7 +171,7 @@ function compact(io::AbstractIOBuffer) return io end -function ensureroom(io::AbstractIOBuffer, nshort::Int) +@inline function ensureroom(io::AbstractIOBuffer, nshort::Int) io.writable || throw(ArgumentError("ensureroom failed, IOBuffer is not writeable")) if !io.seekable nshort >= 0 || throw(ArgumentError("ensureroom failed, requested number of bytes must be ≥ 0, got $nshort")) @@ -198,7 +198,7 @@ end eof(io::AbstractIOBuffer) = (io.ptr-1 == io.size) -function close{T}(io::AbstractIOBuffer{T}) +@noinline function close{T}(io::AbstractIOBuffer{T}) io.readable = false io.writable = false io.seekable = false @@ -310,12 +310,12 @@ function write_sub{T}(to::AbstractIOBuffer, a::AbstractArray{T}, offs, nel) written += write(to, a[i]) end end - written + return written end write(to::AbstractIOBuffer, a::Array) = write_sub(to, a, 1, length(a)) -function write(to::AbstractIOBuffer, a::UInt8) +@inline function write(to::AbstractIOBuffer, a::UInt8) ensureroom(to, 1) ptr = (to.append ? to.size+1 : to.ptr) if ptr > to.maxsize @@ -325,7 +325,7 @@ function write(to::AbstractIOBuffer, a::UInt8) end to.size = max(to.size, ptr) if !to.append to.ptr += 1 end - sizeof(UInt8) + return sizeof(UInt8) end function readbytes!(io::AbstractIOBuffer, b::Array{UInt8}, nb=length(b))