-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,12 +43,10 @@ const TAGS = Any[ | |
|
||
const ser_version = 3 # do not make changes without bumping the version #! | ||
|
||
const NTAGS = length(TAGS) | ||
|
||
function sertag(v::ANY) | ||
ptr = pointer_from_objref(v) | ||
ptags = convert(Ptr{Ptr{Void}}, pointer(TAGS)) | ||
@inbounds for i = 1:NTAGS | ||
@inbounds for i in eachindex(TAGS) | ||
ptr == unsafe_load(ptags,i) && return (i+1)%Int32 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dfdx
Author
Contributor
|
||
end | ||
return Int32(-1) | ||
|
@@ -116,16 +114,16 @@ function serialize(s::SerializationState, t::Tuple) | |
writetag(s.io, LONGTUPLE_TAG) | ||
write(s.io, Int32(l)) | ||
end | ||
for i = 1:l | ||
serialize(s, t[i]) | ||
for e in t | ||
serialize(s, e) | ||
end | ||
end | ||
|
||
function serialize(s::SerializationState, v::SimpleVector) | ||
writetag(s.io, SIMPLEVECTOR_TAG) | ||
write(s.io, Int32(length(v))) | ||
for i = 1:length(v) | ||
serialize(s, v[i]) | ||
for e in v | ||
serialize(s, e) | ||
end | ||
end | ||
|
||
|
@@ -195,7 +193,7 @@ function serialize(s::SerializationState, a::Array) | |
if isbits(elty) | ||
serialize_array_data(s.io, a) | ||
else | ||
for i = 1:length(a) | ||
for i in eachindex(a) | ||
This comment has been minimized.
Sorry, something went wrong.
nalimilan
Member
|
||
if isdefined(a, i) | ||
serialize(s, a[i]) | ||
else | ||
|
@@ -260,7 +258,7 @@ function serialize(s::SerializationState, ex::Expr) | |
end | ||
serialize(s, ex.head) | ||
serialize(s, ex.typ) | ||
for a = ex.args | ||
for a in ex.args | ||
serialize(s, a) | ||
end | ||
end | ||
|
@@ -615,7 +613,7 @@ function deserialize_array(s::SerializationState) | |
end | ||
A = Array(elty, dims) | ||
deserialize_cycle(s, A) | ||
for i = 1:length(A) | ||
for i = eachindex(A) | ||
tag = Int32(read(s.io, UInt8)::UInt8) | ||
if tag != UNDEFREF_TAG | ||
A[i] = handle_deserialize(s, tag) | ||
|
Ugh. This doesn't sound correct at all. This only passed @timholy's review because he's on holiday! When I think I was bikeshedding with Tony about variable's when this happened... :-)
@dfdx Don't worry about this. Though for your next PR, note that when there are things like
unsafe_*
or conversion toInt*
, better add a FIXME and ask, as these are unlikely to work with non-integer indices. Here,unsafe_load
only accepts an integer as second argument.I've made a PR at #15498.