Skip to content

Commit 07af05e

Browse files
authored
use if instead of short-circuiting && or || (#29)
Should result in finer-grained code coverage.
1 parent 871a13d commit 07af05e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/FixedSizeArrays.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ function checked_dims_impl(a::Int, t::Tuple{Int,Vararg{Int,N}}) where {N}
4747
throw(ArgumentError("array dimension size can't be negative"))
4848
end
4949
(m, o) = Base.Checked.mul_with_overflow(a, b)
50-
o && throw(ArgumentError("array dimensions too great, can't represent length"))
50+
if o
51+
throw(ArgumentError("array dimensions too great, can't represent length"))
52+
end
5153
r = Base.tail(t)::NTuple{N,Int}
5254
checked_dims_impl(m, r)::Int
5355
end
@@ -85,8 +87,9 @@ axes_are_one_based(axes) = all(isone ∘ first, axes)
8587

8688
function FixedSizeArray{T,N}(src::AbstractArray{S,N}) where {T,N,S}
8789
axs = axes(src)
88-
axes_are_one_based(axs) ||
90+
if !axes_are_one_based(axs)
8991
throw(DimensionMismatch("source array has a non-one-based indexing axis"))
92+
end
9093
# Can't use `Base.size` because, according to it's doc string, it's not
9194
# available for all `AbstractArray` types.
9295
size = map(length, axs)
@@ -107,8 +110,9 @@ Base.convert(::Type{T}, a::AbstractArray) where {T<:FixedSizeArray} = T(a)::T
107110

108111
Base.@propagate_inbounds function copyto5!(dst, doff, src, soff, n)
109112
if !iszero(n)
110-
(n < false) &&
113+
if n < false
111114
throw(ArgumentError("the number of elements to copy must be nonnegative"))
115+
end
112116
@boundscheck checkbounds(dst, doff:doff+n-1)
113117
@boundscheck checkbounds(src, soff:soff+n-1)
114118
@inbounds let d, s

0 commit comments

Comments
 (0)