Skip to content

Commit 685606d

Browse files
committed
Use unsafe store instead of copy.
No performance change but reduces bytes allocated by ~5%.
1 parent 1d9a7d0 commit 685606d

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/UDF.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,16 @@ function stepfunc(init, func, fsym=symbol(string(func)*"_step"))
113113
# copy serialized return value
114114
unsafe_copy!(valptr, pointer(funcret), newsize)
115115

116-
# following copies are easier with arrays
117-
acptr = pointer_to_array(acptr, acsize, false)
118116
# copy the size of the serialized value
119117
unsafe_copy!(
120-
acptr, 1,
121-
reinterpret(UInt8, [newsize]), 1,
122-
intsize,
118+
acptr,
119+
pointer(reinterpret(UInt8, [newsize])),
120+
intsize
123121
)
124122
# copy the address of the pointer to the serialized value
125-
unsafe_copy!(
126-
acptr, intsize+1,
127-
reinterpret(UInt8, [valptr]), 1,
128-
ptrsize,
129-
)
123+
for (i, byte) in enumerate(reinterpret(UInt8, [valptr]))
124+
unsafe_store!(acptr, byte, intsize+i)
125+
end
130126
catch
131127
# TODO:
132128
# this won't catch all memory leaks so add an else clause

0 commit comments

Comments
 (0)