@@ -46,7 +46,7 @@ ply_type_name(::Float64) = "float64"
4646
4747const PlyNativeType = Union{UInt8,UInt16,UInt32,UInt64,Int8,Int16,Int32,Int64,Float32,Float64}
4848
49- ply_type_name {T<:PlyNativeType} (A:: AbstractArray{T} ) = ply_type_name (T)
49+ ply_type_name (A:: AbstractArray{T} ) where {T <: PlyNativeType } = ply_type_name (T)
5050
5151ply_type_name (A:: AbstractArray ) = ! isempty (A) ? ply_type_name (A[1 ]) :
5252 error (" Unknown ply element type name for empty array of type $(typeof (A)) " )
@@ -124,13 +124,13 @@ function write_header_field(stream::IO, prop::ArrayProperty)
124124 println (stream, " property $(ply_type_name (prop. data)) $(prop. name) " )
125125end
126126
127- function write_header_field {T,Names<:PropNameList} (stream:: IO , prop:: ArrayProperty{T,Names} )
127+ function write_header_field (stream:: IO , prop:: ArrayProperty{T,Names} ) where {T,Names <: PropNameList }
128128 for n in prop. name
129129 println (stream, " property $(ply_type_name (prop. data)) $(n) " )
130130 end
131131end
132132
133- function write_header_field {S} (stream:: IO , prop:: ListProperty{S} )
133+ function write_header_field (stream:: IO , prop:: ListProperty{S} ) where {S}
134134 println (stream, " property list $(ply_type_name (S)) $(ply_type_name (prop. data)) $(prop. name) " )
135135end
136136
165165# -------------------------------------------------------------------------------
166166# ASCII IO for properties and elements
167167
168- function parse_ascii {T} (:: Type{T} , io:: IO )
168+ function parse_ascii (:: Type{T} , io:: IO ) where {T}
169169 # FIXME : sadly unbuffered, will probably have terrible performance.
170170 buf = UInt8[]
171171 while ! eof (io)
@@ -181,10 +181,10 @@ function parse_ascii{T}(::Type{T}, io::IO)
181181 parse (T, String (buf))
182182end
183183
184- function read_ascii_value! {T} (stream:: IO , prop:: ArrayProperty{T} , index)
184+ function read_ascii_value! (stream:: IO , prop:: ArrayProperty{T} , index) where {T}
185185 prop. data[index] = parse_ascii (T, stream)
186186end
187- function read_ascii_value! {S,T} (stream:: IO , prop:: ListProperty{S,T} , index)
187+ function read_ascii_value! (stream:: IO , prop:: ListProperty{S,T} , index) where {S,T}
188188 N = parse_ascii (S, stream)
189189 prop. start_inds[index+ 1 ] = prop. start_inds[index] + N
190190 for i= 1 : N
@@ -198,20 +198,20 @@ end
198198
199199# --------------------------------------------------
200200# property IO
201- function read_binary_value! {T} (stream:: IO , prop:: ArrayProperty{T} , index)
201+ function read_binary_value! (stream:: IO , prop:: ArrayProperty{T} , index) where {T}
202202 prop. data[index] = read (stream, T)
203203end
204- function read_binary_value! {S,T} (stream:: IO , prop:: ListProperty{S,T} , index)
204+ function read_binary_value! (stream:: IO , prop:: ListProperty{S,T} , index) where {S,T}
205205 N = read (stream, S)
206206 prop. start_inds[index+ 1 ] = prop. start_inds[index] + N
207- inds = read (stream, T , Int (N))
207+ inds = read! (stream, Vector {T} (undef , Int (N) ))
208208 append! (prop. data, inds)
209209end
210210
211211function write_binary_value (stream:: IO , prop:: ArrayProperty , index)
212212 write (stream, prop. data[index])
213213end
214- function write_binary_value {S} (stream:: IO , prop:: ListProperty{S} , index)
214+ function write_binary_value (stream:: IO , prop:: ListProperty{S} , index) where {S}
215215 len = prop. start_inds[index+ 1 ] - prop. start_inds[index]
216216 write (stream, convert (S, len))
217217 esize = sizeof (eltype (prop. data))
230230function write_ascii_value (stream:: IO , prop:: ArrayProperty , index)
231231 print (stream, prop. data[index])
232232end
233- function write_ascii_value {T<:AbstractArray} (stream:: IO , prop:: ArrayProperty{T } , index)
233+ function write_ascii_value (stream:: IO , prop:: ArrayProperty{<:AbstractArray } , index)
234234 p = prop. data[index]
235235 for i = 1 : length (p)
236236 if i != 1
290290# for elements constructed of simple arrays with homogenous type -
291291# serialization speed generally seems to be limited by the many individual
292292# calls to write() with small buffers.
293- function write_binary_values {T} (stream:: IO , elen, props:: ArrayProperty{T} ...)
293+ function write_binary_values (stream:: IO , elen, props:: ArrayProperty{T} ...) where {T}
294294 batchsize = 100
295295 numprops = length (props)
296296 buf = Matrix {T} (numprops, batchsize)
0 commit comments