@@ -131,7 +131,7 @@ checkbounds(::Type{Bool}, sz::Integer, i) = throw(ArgumentError("unable to check
131
131
checkbounds (:: Type{Bool} , sz:: Integer , i:: Real ) = 1 <= i <= sz
132
132
checkbounds (:: Type{Bool} , sz:: Integer , :: Colon ) = true
133
133
function checkbounds (:: Type{Bool} , sz:: Integer , r:: Range )
134
- @_inline_meta
134
+ @_propagate_inbounds_meta
135
135
isempty (r) || (checkbounds (Bool, sz, minimum (r)) && checkbounds (Bool, sz, maximum (r)))
136
136
end
137
137
checkbounds (:: Type{Bool} , sz:: Integer , I:: AbstractArray{Bool} ) = length (I) == sz
@@ -350,8 +350,8 @@ function copy!{R,S}(B::AbstractVecOrMat{R}, ir_dest::Range{Int}, jr_dest::Range{
350
350
throw (ArgumentError (string (" source and destination must have same size (got " ,
351
351
length (jr_src)," and " ,length (jr_dest)," )" )))
352
352
end
353
- checkbounds (B, ir_dest, jr_dest)
354
- checkbounds (A, ir_src, jr_src)
353
+ @boundscheck checkbounds (B, ir_dest, jr_dest)
354
+ @boundscheck checkbounds (A, ir_src, jr_src)
355
355
jdest = first (jr_dest)
356
356
for jsrc in jr_src
357
357
idest = first (ir_dest)
@@ -374,8 +374,8 @@ function copy_transpose!{R,S}(B::AbstractVecOrMat{R}, ir_dest::Range{Int}, jr_de
374
374
throw (ArgumentError (string (" source and destination must have same size (got " ,
375
375
length (ir_src)," and " ,length (jr_dest)," )" )))
376
376
end
377
- checkbounds (B, ir_dest, jr_dest)
378
- checkbounds (A, ir_src, jr_src)
377
+ @boundscheck checkbounds (B, ir_dest, jr_dest)
378
+ @boundscheck checkbounds (A, ir_src, jr_src)
379
379
idest = first (ir_dest)
380
380
for jsrc in jr_src
381
381
jdest = first (jr_dest)
@@ -476,35 +476,35 @@ pointer{T}(x::AbstractArray{T}, i::Integer) = (@_inline_meta; unsafe_convert(Ptr
476
476
# unsafe method.
477
477
478
478
function getindex (A:: AbstractArray , I... )
479
- @_inline_meta
479
+ @_propagate_inbounds_meta
480
480
_getindex (linearindexing (A), A, I... )
481
481
end
482
482
function unsafe_getindex (A:: AbstractArray , I... )
483
- @_inline_meta
483
+ @_propagate_inbounds_meta
484
484
_unsafe_getindex (linearindexing (A), A, I... )
485
485
end
486
486
# # Internal defitions
487
487
# 0-dimensional indexing is defined to prevent ambiguities. LinearFast is easy:
488
- _getindex (:: LinearFast , A:: AbstractArray ) = (@_inline_meta ; getindex (A, 1 ))
488
+ _getindex (:: LinearFast , A:: AbstractArray ) = (@_propagate_inbounds_meta ; getindex (A, 1 ))
489
489
# But LinearSlow must take into account the dimensionality of the array:
490
490
_getindex {T} (:: LinearSlow , A:: AbstractArray{T,0} ) = error (" indexing not defined for " , typeof (A))
491
- _getindex (:: LinearSlow , A:: AbstractVector ) = (@_inline_meta ; getindex (A, 1 ))
492
- _getindex (l:: LinearSlow , A:: AbstractArray ) = (@_inline_meta ; _getindex (l, A, 1 ))
491
+ _getindex (:: LinearSlow , A:: AbstractVector ) = (@_propagate_inbounds_meta ; getindex (A, 1 ))
492
+ _getindex (l:: LinearSlow , A:: AbstractArray ) = (@_propagate_inbounds_meta ; _getindex (l, A, 1 ))
493
493
_unsafe_getindex (:: LinearFast , A:: AbstractArray ) = (@_inline_meta ; unsafe_getindex (A, 1 ))
494
494
_unsafe_getindex {T} (:: LinearSlow , A:: AbstractArray{T,0} ) = error (" indexing not defined for " , typeof (A))
495
495
_unsafe_getindex (:: LinearSlow , A:: AbstractVector ) = (@_inline_meta ; unsafe_getindex (A, 1 ))
496
496
_unsafe_getindex (l:: LinearSlow , A:: AbstractArray ) = (@_inline_meta ; _unsafe_getindex (l, A, 1 ))
497
497
498
498
_getindex (:: LinearIndexing , A:: AbstractArray , I... ) = error (" indexing $(typeof (A)) with types $(typeof (I)) is not supported" )
499
- _unsafe_getindex (:: LinearIndexing , A:: AbstractArray , I... ) = (@_inline_meta ; getindex (A, I... ))
499
+ _unsafe_getindex (:: LinearIndexing , A:: AbstractArray , I... ) = (@_propagate_inbounds_meta ; getindex (A, I... ))
500
500
501
501
# # LinearFast Scalar indexing
502
502
_getindex (:: LinearFast , A:: AbstractArray , I:: Int ) = error (" indexing not defined for " , typeof (A))
503
503
function _getindex (:: LinearFast , A:: AbstractArray , I:: Real... )
504
504
@_inline_meta
505
505
# We must check bounds for sub2ind; so we can then call unsafe_getindex
506
506
J = to_indexes (I... )
507
- checkbounds (A, J... )
507
+ @boundscheck checkbounds (A, J... )
508
508
unsafe_getindex (A, sub2ind (size (A), J... ))
509
509
end
510
510
_unsafe_getindex (:: LinearFast , A:: AbstractArray , I:: Real ) = (@_inline_meta ; getindex (A, I))
@@ -520,14 +520,14 @@ end
520
520
if all (x-> x=== Int, I)
521
521
:(error (" indexing not defined for " , typeof (A)))
522
522
else
523
- :($ (Expr (:meta , :inline )); getindex (A, to_indexes (I... )... ))
523
+ :($ (Expr (:meta , :inline , :propagate_inbounds )); getindex (A, to_indexes (I... )... ))
524
524
end
525
525
elseif N > AN
526
526
# Drop trailing ones
527
527
Isplat = Expr[:(I[$ d]) for d = 1 : AN]
528
528
Osplat = Expr[:(to_index (I[$ d]) == 1 ) for d = AN+ 1 : N]
529
529
quote
530
- $ (Expr (:meta , :inline ))
530
+ $ (Expr (:meta , :inline , :propagate_inbounds ))
531
531
(& )($ (Osplat... )) || throw_boundserror (A, I)
532
532
getindex (A, $ (Isplat... ))
533
533
end
542
542
sz. args = Expr[:(size (A, $ d)) for d= N: AN]
543
543
szcheck = Expr[:(size (A, $ d) > 0 ) for d= N: AN]
544
544
quote
545
- $ (Expr (:meta , :inline ))
545
+ $ (Expr (:meta , :inline , :propagate_inbounds ))
546
546
# ind2sub requires all dimensions to be > 0:
547
547
(& )($ (szcheck... )) || throw_boundserror (A, I)
548
548
s = ind2sub ($ sz, to_index (I[$ N]))
@@ -553,12 +553,12 @@ end
553
553
@generated function _unsafe_getindex {T,AN} (:: LinearSlow , A:: AbstractArray{T,AN} , I:: Real... )
554
554
N = length (I)
555
555
if N == AN
556
- :($ (Expr (:meta , :inline )); getindex (A, I... ))
556
+ :($ (Expr (:meta , :inline , :propagate_inbounds )); getindex (A, I... ))
557
557
elseif N > AN
558
558
# Drop trailing dimensions (unchecked)
559
559
Isplat = Expr[:(I[$ d]) for d = 1 : AN]
560
560
quote
561
- $ (Expr (:meta , :inline ))
561
+ $ (Expr (:meta , :inline , :propagate_inbounds ))
562
562
unsafe_getindex (A, $ (Isplat... ))
563
563
end
564
564
else
570
570
sz = Expr (:tuple )
571
571
sz. args = Expr[:(size (A, $ d)) for d= N: AN]
572
572
quote
573
- $ (Expr (:meta , :inline ))
573
+ $ (Expr (:meta , :inline , :propagate_inbounds ))
574
574
s = ind2sub ($ sz, to_index (I[$ N]))
575
575
unsafe_getindex (A, $ (Isplat... ))
576
576
end
@@ -580,33 +580,33 @@ end
580
580
# # Setindex! is defined similarly. We first dispatch to an internal _setindex!
581
581
# function that allows dispatch on array storage
582
582
function setindex! (A:: AbstractArray , v, I... )
583
- @_inline_meta
583
+ @_propagate_inbounds_meta
584
584
_setindex! (linearindexing (A), A, v, I... )
585
585
end
586
586
function unsafe_setindex! (A:: AbstractArray , v, I... )
587
- @_inline_meta
587
+ @_propagate_inbounds_meta
588
588
_unsafe_setindex! (linearindexing (A), A, v, I... )
589
589
end
590
590
# # Internal defitions
591
- _setindex! (:: LinearFast , A:: AbstractArray , v) = (@_inline_meta ; setindex! (A, v, 1 ))
591
+ _setindex! (:: LinearFast , A:: AbstractArray , v) = (@_propagate_inbounds_meta ; setindex! (A, v, 1 ))
592
592
_setindex! {T} (:: LinearSlow , A:: AbstractArray{T,0} , v) = error (" indexing not defined for " , typeof (A))
593
- _setindex! (:: LinearSlow , A:: AbstractVector , v) = (@_inline_meta ; setindex! (A, v, 1 ))
594
- _setindex! (l:: LinearSlow , A:: AbstractArray , v) = (@_inline_meta ; _setindex! (l, A, v, 1 ))
593
+ _setindex! (:: LinearSlow , A:: AbstractVector , v) = (@_propagate_inbounds_meta ; setindex! (A, v, 1 ))
594
+ _setindex! (l:: LinearSlow , A:: AbstractArray , v) = (@_propagate_inbounds_meta ; _setindex! (l, A, v, 1 ))
595
595
_unsafe_setindex! (:: LinearFast , A:: AbstractArray , v) = (@_inline_meta ; unsafe_setindex! (A, v, 1 ))
596
596
_unsafe_setindex! {T} (:: LinearSlow , A:: AbstractArray{T,0} , v) = error (" indexing not defined for " , typeof (A))
597
597
_unsafe_setindex! (:: LinearSlow , A:: AbstractVector , v) = (@_inline_meta ; unsafe_setindex! (A, v, 1 ))
598
598
_unsafe_setindex! (l:: LinearSlow , A:: AbstractArray , v) = (@_inline_meta ; _unsafe_setindex! (l, A, v, 1 ))
599
599
600
600
_setindex! (:: LinearIndexing , A:: AbstractArray , v, I... ) = error (" indexing $(typeof (A)) with types $(typeof (I)) is not supported" )
601
- _unsafe_setindex! (:: LinearIndexing , A:: AbstractArray , v, I... ) = (@_inline_meta ; setindex! (A, v, I... ))
601
+ _unsafe_setindex! (:: LinearIndexing , A:: AbstractArray , v, I... ) = (@_propagate_inbounds_meta ; setindex! (A, v, I... ))
602
602
603
603
# # LinearFast Scalar indexing
604
604
_setindex! (:: LinearFast , A:: AbstractArray , v, I:: Int ) = error (" indexed assignment not defined for " , typeof (A))
605
605
function _setindex! (:: LinearFast , A:: AbstractArray , v, I:: Real... )
606
606
@_inline_meta
607
607
# We must check bounds for sub2ind; so we can then call unsafe_setindex!
608
608
J = to_indexes (I... )
609
- checkbounds (A, J... )
609
+ @boundscheck checkbounds (A, J... )
610
610
unsafe_setindex! (A, v, sub2ind (size (A), J... ))
611
611
end
612
612
_unsafe_setindex! (:: LinearFast , A:: AbstractArray , v, I:: Real ) = (@_inline_meta ; setindex! (A, v, I))
@@ -622,14 +622,14 @@ end
622
622
if all (x-> x=== Int, I)
623
623
:(error (" indexing not defined for " , typeof (A)))
624
624
else
625
- :($ (Expr (:meta , :inline )); setindex! (A, v, to_indexes (I... )... ))
625
+ :($ (Expr (:meta , :inline , :propagate_inbounds )); setindex! (A, v, to_indexes (I... )... ))
626
626
end
627
627
elseif N > AN
628
628
# Drop trailing ones
629
629
Isplat = Expr[:(I[$ d]) for d = 1 : AN]
630
630
Osplat = Expr[:(to_index (I[$ d]) == 1 ) for d = AN+ 1 : N]
631
631
quote
632
- $ (Expr (:meta , :inline ))
632
+ $ (Expr (:meta , :inline , :propagate_inbounds ))
633
633
(& )($ (Osplat... )) || throw_boundserror (A, I)
634
634
setindex! (A, v, $ (Isplat... ))
635
635
end
644
644
sz. args = Expr[:(size (A, $ d)) for d= N: AN]
645
645
szcheck = Expr[:(size (A, $ d) > 0 ) for d= N: AN]
646
646
quote
647
- $ (Expr (:meta , :inline ))
647
+ $ (Expr (:meta , :inline , :propagate_inbounds ))
648
648
# ind2sub requires all dimensions to be > 0:
649
649
(& )($ (szcheck... )) || throw_boundserror (A, I)
650
650
s = ind2sub ($ sz, to_index (I[$ N]))
660
660
# Drop trailing dimensions (unchecked)
661
661
Isplat = Expr[:(I[$ d]) for d = 1 : AN]
662
662
quote
663
- $ (Expr (:meta , :inline ))
663
+ $ (Expr (:meta , :inline , :propagate_inbounds ))
664
664
unsafe_setindex! (A, v, $ (Isplat... ))
665
665
end
666
666
else
672
672
sz = Expr (:tuple )
673
673
sz. args = Expr[:(size (A, $ d)) for d= N: AN]
674
674
quote
675
- $ (Expr (:meta , :inline ))
675
+ $ (Expr (:meta , :inline , :propagate_inbounds ))
676
676
s = ind2sub ($ sz, to_index (I[$ N]))
677
677
unsafe_setindex! (A, v, $ (Isplat... ))
678
678
end
0 commit comments