[m-rev.] diff: avoid bounds checks in unsafe array2d ops
Julien Fischer
juliensf at csse.unimelb.edu.au
Thu May 17 12:22:42 AEST 2012
Branches: main, 11.07
library/array2d.m:
When implementing unsafe array2d operations call the
corresponding unsafe operations in the array module.
tests/hard_coded/version_array_test.exp:
Conform to recent changes to the version_array module.
Julien.
Index: library/array2d.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/array2d.m,v
retrieving revision 1.12
diff -u -r1.12 array2d.m
--- library/array2d.m 8 May 2011 16:02:22 -0000 1.12
+++ library/array2d.m 17 May 2012 01:23:08 -0000
@@ -193,7 +193,7 @@
%-----------------------------------------------------------------------------%
-array2d(_M, N, A) ^ unsafe_elem(I, J) = A ^ elem(I * N + J).
+array2d(_M, N, A) ^ unsafe_elem(I, J) = A ^ unsafe_elem(I * N + J).
%-----------------------------------------------------------------------------%
@@ -208,7 +208,7 @@
%-----------------------------------------------------------------------------%
( array2d(M, N, A) ^ unsafe_elem(I, J) := X ) =
- array2d(M, N, A ^ elem(I * N + J) := X).
+ array2d(M, N, A ^ unsafe_elem(I * N + J) := X).
unsafe_set(I, J, X, A, A ^ unsafe_elem(I, J) := X).
Index: tests/hard_coded/version_array_test.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/version_array_test.exp,v
retrieving revision 1.3
diff -u -r1.3 version_array_test.exp
--- tests/hard_coded/version_array_test.exp 30 May 2007 02:42:46 -0000 1.3
+++ tests/hard_coded/version_array_test.exp 17 May 2012 02:16:59 -0000
@@ -12,8 +12,8 @@
7, 7, 7, 7, 9, 9, 9, 9, 9 (size 9)
(sum 73)
7, 7, 7, 7 (size 4)
-Found exception as expected: software_error("version_array.elem: index out of range")
-Found exception as expected: software_error("version_array.\'elem :=\': index out of range")
-Found exception as expected: software_error("version_array.\'elem :=\': index out of range")
-Found exception as expected: software_error("version_array.elem: index out of range")
-Found exception as expected: software_error("version_array.elem: index out of range")
+Found exception as expected: index_out_of_bounds("version_array.elem: index -1 not in range [0, 3]")
+Found exception as expected: index_out_of_bounds("version_array.\'elem :=\': index -1 not in range [0, 3]")
+Found exception as expected: index_out_of_bounds("version_array.\'elem :=\': index -1 not in range [0, 3]")
+Found exception as expected: index_out_of_bounds("version_array.elem: index -1 not in range [0, 3]")
+Found exception as expected: index_out_of_bounds("version_array.elem: index 4 not in range [0, 3]")
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list