@@ -3,22 +3,22 @@ using OffsetArrays
3
3
4
4
const dim = 1000
5
5
6
- x = Array ( Float64, 2 * dim)
7
- y = OffsetArray ( Float64, - dim + 1 : dim)
8
- x2d = Array ( Float64, 2 * dim, 2 * dim)
9
- y2d = OffsetArray ( Float64, - dim + 1 : dim, - dim + 1 : dim)
6
+ x = Array { Float64} (undef , 2 * dim)
7
+ y = OffsetArray { Float64} (undef , - dim + 1 : dim)
8
+ x2d = Array { Float64} (undef , 2 * dim, 2 * dim)
9
+ y2d = OffsetArray { Float64} (undef , - dim + 1 : dim, - dim + 1 : dim)
10
10
11
- fill (x) = for i in indices (x,1 ); x[i] = i; end
12
- fill2d (x) = for j in indices (x,2 ); for i in indices (x,1 ); x[i,j] = i + j; end ; end
13
- update (x) = for i in indices (x,1 ); x[i] = x[i] + i; end
14
- update2d (x) = for j in indices (x,2 ); for i in indices (x,1 ); x[i,j] = x[i,j] + i + j; end ; end
11
+ fill (x) = for i in axes (x,1 ); x[i] = i; end
12
+ fill2d (x) = for j in axes (x,2 ); for i in axes (x,1 ); x[i,j] = i + j; end ; end
13
+ update (x) = for i in axes (x,1 ); x[i] = x[i] + i; end
14
+ update2d (x) = for j in axes (x,2 ); for i in axes (x,1 ); x[i,j] = x[i,j] + i + j; end ; end
15
15
update_eachindex (x) = for i in eachindex (x); x[i] = x[i] + i; end
16
16
17
- unsafe_fill (x) = @unsafe (for i in indices (x,1 ); x[i] = i; end )
18
- unsafe_fill2d (x) = @unsafe (for j in indices (x,2 ); for i in indices (x,1 ); x[i,j] = i + j; end ; end )
19
- unsafe_update (x) = @unsafe (for i in indices (x,1 ); x[i] = x[i] + i; end )
20
- unsafe_update2d (x) = @unsafe (for j in indices (x,2 ); for i in indices (x,1 ); x[i,j] = x[i,j] + i + j; end ; end )
21
- unsafe_update_eachindex (x) = @unsafe (for i in eachindex (x); x[i] = x[i] + i; end )
17
+ unsafe_fill (x) = @inbounds (for i in axes (x,1 ); x[i] = i; end )
18
+ unsafe_fill2d (x) = @inbounds (for j in axes (x,2 ); for i in axes (x,1 ); x[i,j] = i + j; end ; end )
19
+ unsafe_update (x) = @inbounds (for i in axes (x,1 ); x[i] = x[i] + i; end )
20
+ unsafe_update2d (x) = @inbounds (for j in axes (x,2 ); for i in axes (x,1 ); x[i,j] = x[i,j] + i + j; end ; end )
21
+ unsafe_update_eachindex (x) = @inbounds (for i in eachindex (x); x[i] = x[i] + i; end )
22
22
23
23
@show @benchmark fill (x)
24
24
@show @benchmark fill (y)
0 commit comments