JuliaLang/julia

fix mistake in methods()

`a couple misc things`
1 parent 56f7a56 commit a69fb63d7e06ef2c88c654954b4d24563cac446c JeffBezanson committed Aug 29, 2012
Showing with 12 additions and 7 deletions.
1. +7 −5 base/array.jl
2. +1 −0 base/number.jl
3. +2 −1 base/util.jl
4. +2 −1 src/array.c
 @@ -728,10 +728,14 @@ function append!{T}(a::Array{T,1}, items::Array{T,1}) end function grow(a::Vector, n::Integer) - if n < -length(a) - throw(BoundsError()) + if n > 0 + ccall(:jl_array_grow_end, Void, (Any, Uint), a, n) + else + if n < -length(a) + throw(BoundsError()) + end + ccall(:jl_array_del_end, Void, (Any, Uint), a, -n) end - ccall(:jl_array_grow_end, Void, (Any, Uint), a, n) return a end @@ -1332,8 +1336,6 @@ end ## Reductions ## -contains(s::Number, n::Number) = (s == n) - areduce{T}(f::Function, A::StridedArray{T}, region::Dimspec, v0) = areduce(f,A,region,v0,T)
 @@ -37,5 +37,6 @@ start(a::Real) = a next(a::Real, i) = (a, a+1) done(a::Real, i) = (i > a) isempty(a::Number) = false +contains(s::Number, n::Number) = (s == n) reinterpret{T<:Real}(::Type{T}, x::Real) = box(T,x)
 @@ -159,7 +159,8 @@ function methods(f::Function) f.env end -methods(t::CompositeKind) = methods(t,Tuple) +methods(t::CompositeKind) = (methods(t,Tuple); # force constructor creation + t.env) # require
 @@ -454,7 +454,8 @@ void jl_array_del_end(jl_array_t *a, size_t dec) { if (dec > a->length) jl_error("array_del_end: index out of range"); - memset((char*)a->data + (a->length-dec)*a->elsize, 0, dec*a->elsize); + if (a->ptrarray) + memset((char*)a->data + (a->length-dec)*a->elsize, 0, dec*a->elsize); a->length -= dec; a->nrows -= dec; }