diff options
author | Daniel Llorens <daniel.llorens@bluewin.ch> | 2013-04-08 13:34:41 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-02-06 11:33:08 +0100 |
commit | 5e8c9d4ad5d225611f340cdcf285aee7c8a1908a (patch) | |
tree | 9045580787a87923b1c0ececb382faaa867aa5ce /libguile/array-map.c | |
parent | c4aca3b9da9e7777f84efcd304990ad78b883f07 (diff) | |
download | guile-5e8c9d4ad5d225611f340cdcf285aee7c8a1908a.tar.gz |
Don't use generalized-vector in array-map.c (I)
* array-map.c: (AREF, ASET): Rename from GVREF, GVSET and use rank-1
array accessors.
Diffstat (limited to 'libguile/array-map.c')
-rw-r--r-- | libguile/array-map.c | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/libguile/array-map.c b/libguile/array-map.c index e47fb5641..ec9aac469 100644 --- a/libguile/array-map.c +++ b/libguile/array-map.c @@ -1,5 +1,5 @@ /* Copyright (C) 1996, 1998, 2000, 2001, 2004, 2005, 2006, 2008, 2009, - * 2010, 2011, 2012, 2013 Free Software Foundation, Inc. + * 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -48,9 +48,17 @@ /* The WHAT argument for `scm_gc_malloc ()' et al. */ static const char indices_gc_hint[] = "array-indices"; +static SCM +AREF (SCM v, size_t pos) +{ + return scm_c_array_ref_1 (v, pos); +} -#define GVREF scm_c_generalized_vector_ref -#define GVSET scm_c_generalized_vector_set_x +static void +ASET (SCM v, size_t pos, SCM val) +{ + scm_c_array_set_1_x (v, val, pos); +} static unsigned long cind (SCM ra, long *ve) @@ -407,7 +415,7 @@ scm_array_fill_int (SCM ra, SCM fill, SCM ignore SCM_UNUSED) ra = SCM_I_ARRAY_V (ra); for (i = base; n--; i += inc) - GVSET (ra, i, fill); + ASET (ra, i, fill); return 1; } @@ -437,7 +445,7 @@ scm_ra_eqp (SCM ra0, SCM ras) { for (; n-- > 0; i0 += inc0, i1 += inc1, i2 += inc2) if (scm_is_true (scm_array_handle_ref (&ra0_handle, i0))) - if (!scm_is_eq (GVREF (ra1, i1), GVREF (ra2, i2))) + if (!scm_is_eq (AREF (ra1, i1), AREF (ra2, i2))) scm_array_handle_set (&ra0_handle, i0, SCM_BOOL_F); } @@ -470,8 +478,8 @@ ra_compare (SCM ra0, SCM ra1, SCM ra2, int opt) for (; n-- > 0; i0 += inc0, i1 += inc1, i2 += inc2) if (scm_is_true (scm_array_handle_ref (&ra0_handle, i0))) if (opt ? - scm_is_true (scm_less_p (GVREF (ra1, i1), GVREF (ra2, i2))) : - scm_is_false (scm_less_p (GVREF (ra1, i1), GVREF (ra2, i2)))) + scm_is_true (scm_less_p (AREF (ra1, i1), AREF (ra2, i2))) : + scm_is_false (scm_less_p (AREF (ra1, i1), AREF (ra2, i2)))) scm_array_handle_set (&ra0_handle, i0, SCM_BOOL_F); } @@ -527,7 +535,7 @@ scm_ra_sum (SCM ra0, SCM ras) default: { for (; n-- > 0; i0 += inc0, i1 += inc1) - GVSET (ra0, i0, scm_sum (GVREF(ra0, i0), GVREF(ra1, i1))); + ASET (ra0, i0, scm_sum (AREF(ra0, i0), AREF(ra1, i1))); break; } } @@ -551,7 +559,7 @@ scm_ra_difference (SCM ra0, SCM ras) default: { for (; n-- > 0; i0 += inc0) - GVSET (ra0, i0, scm_difference (GVREF(ra0, i0), SCM_UNDEFINED)); + ASET (ra0, i0, scm_difference (AREF(ra0, i0), SCM_UNDEFINED)); break; } } @@ -567,8 +575,7 @@ scm_ra_difference (SCM ra0, SCM ras) default: { for (; n-- > 0; i0 += inc0, i1 += inc1) - GVSET (ra0, i0, scm_difference (GVREF (ra0, i0), - GVREF (ra1, i1))); + ASET (ra0, i0, scm_difference (AREF (ra0, i0), AREF (ra1, i1))); break; } } @@ -596,8 +603,7 @@ scm_ra_product (SCM ra0, SCM ras) default: { for (; n-- > 0; i0 += inc0, i1 += inc1) - GVSET (ra0, i0, scm_product (GVREF (ra0, i0), - GVREF (ra1, i1))); + ASET (ra0, i0, scm_product (AREF (ra0, i0), AREF (ra1, i1))); } } } @@ -619,7 +625,7 @@ scm_ra_divide (SCM ra0, SCM ras) default: { for (; n-- > 0; i0 += inc0) - GVSET (ra0, i0, scm_divide (GVREF (ra0, i0), SCM_UNDEFINED)); + ASET (ra0, i0, scm_divide (AREF (ra0, i0), SCM_UNDEFINED)); break; } } @@ -636,9 +642,8 @@ scm_ra_divide (SCM ra0, SCM ras) { for (; n-- > 0; i0 += inc0, i1 += inc1) { - SCM res = scm_divide (GVREF (ra0, i0), - GVREF (ra1, i1)); - GVSET (ra0, i0, res); + SCM res = scm_divide (AREF (ra0, i0), AREF (ra1, i1)); + ASET (ra0, i0, res); } break; } @@ -693,7 +698,7 @@ ramap (SCM ra0, SCM proc, SCM ras) SCM args = SCM_EOL; unsigned long k; for (k = scm_c_vector_length (ras); k--;) - args = scm_cons (GVREF (scm_c_vector_ref (ras, k), i), args); + args = scm_cons (AREF (scm_c_vector_ref (ras, k), i), args); h0.impl->vset (&h0, i0, scm_apply_1 (proc, h1.impl->vref (&h1, i1), args)); } } @@ -753,7 +758,7 @@ rafe (SCM ra0, SCM proc, SCM ras) SCM args = SCM_EOL; unsigned long k; for (k = scm_c_vector_length (ras); k--;) - args = scm_cons (GVREF (scm_c_vector_ref (ras, k), i), args); + args = scm_cons (AREF (scm_c_vector_ref (ras, k), i), args); scm_apply_1 (proc, h0.impl->vref (&h0, i0), args); } } @@ -823,7 +828,7 @@ SCM_DEFINE (scm_array_index_map_x, "array-index-map!", 2, 0, 0, { for (j = kmax + 1, args = SCM_EOL; j--;) args = scm_cons (scm_from_long (vinds[j]), args); - GVSET (SCM_I_ARRAY_V (ra), i, scm_apply_0 (proc, args)); + ASET (SCM_I_ARRAY_V (ra), i, scm_apply_0 (proc, args)); i += SCM_I_ARRAY_DIMS (ra)[k].inc; } k--; @@ -846,10 +851,10 @@ SCM_DEFINE (scm_array_index_map_x, "array-index-map!", 2, 0, 0, { size_t length = scm_c_generalized_vector_length (ra); for (i = 0; i < length; i++) - GVSET (ra, i, scm_call_1 (proc, scm_from_ulong (i))); + ASET (ra, i, scm_call_1 (proc, scm_from_ulong (i))); return SCM_UNSPECIFIED; } - else + else scm_wrong_type_arg_msg (NULL, 0, ra, "array"); } #undef FUNC_NAME |