Skip to content

Commit d96aece

Browse files
authored
more aggressively inline functions of Memory (#77)
1 parent af43270 commit d96aece

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/memory.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ function Memory(data::ByteData)
1515
return Memory(pointer(data), sizeof(data))
1616
end
1717

18-
function Base.length(mem::Memory)
18+
@inline function Base.length(mem::Memory)
1919
return mem.size
2020
end
2121

22-
function Base.lastindex(mem::Memory)
22+
@inline function Base.lastindex(mem::Memory)
2323
return Int(mem.size)
2424
end
2525

26-
function Base.checkbounds(mem::Memory, i::Integer)
26+
@inline function Base.checkbounds(mem::Memory, i::Integer)
2727
if !(1 i lastindex(mem))
2828
throw(BoundsError(mem, i))
2929
end
3030
end
3131

32-
function Base.getindex(mem::Memory, i::Integer)
32+
@inline function Base.getindex(mem::Memory, i::Integer)
3333
@boundscheck checkbounds(mem, i)
3434
return unsafe_load(mem.ptr, i)
3535
end
3636

37-
function Base.setindex!(mem::Memory, val::UInt8, i::Integer)
37+
@inline function Base.setindex!(mem::Memory, val::UInt8, i::Integer)
3838
@boundscheck checkbounds(mem, i)
3939
return unsafe_store!(mem.ptr, val, i)
4040
end

0 commit comments

Comments
 (0)