1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-13 09:10:26 +02:00

Use string and symbol accessors in struct, throw, and array funcs

* libguile/struct.c (scm_make_struct_layout, scm_struct_init)
  (scm_struct_vtable_p, scm_struct_ref, scm_struct_set_x): use string
  and symbol accessors and avoid unpacking strings and symbols

* libguile/throw.c (scm_ithrow): allow wide symbols in the error message

* libguile/unif.c (scm_enclose_array, scm_istr2bve): use string
  accessors and avoid unpacking strings
This commit is contained in:
Michael Gran 2009-08-22 10:15:53 -07:00
parent 806f1ded95
commit 27646f414e
3 changed files with 48 additions and 48 deletions

View file

@ -1149,7 +1149,6 @@ SCM_DEFINE (scm_enclose_array, "enclose-array", 1, 0, 1,
#define FUNC_NAME s_scm_enclose_array
{
SCM axv, res, ra_inr;
const char *c_axv;
scm_t_array_dim vdim, *s = &vdim;
int ndim, j, k, ninr, noutr;
@ -1197,10 +1196,9 @@ SCM_DEFINE (scm_enclose_array, "enclose-array", 1, 0, 1,
SCM_I_ARRAY_DIMS (ra_inr)[k].inc = s[j].inc;
scm_c_string_set_x (axv, j, SCM_MAKE_CHAR (1));
}
c_axv = scm_i_string_chars (axv);
for (j = 0, k = 0; k < noutr; k++, j++)
{
while (c_axv[j])
while (!scm_i_string_ref (axv, j) == '\0')
j++;
SCM_I_ARRAY_DIMS (res)[k].lbnd = s[j].lbnd;
SCM_I_ARRAY_DIMS (res)[k].ubnd = s[j].ubnd;
@ -2329,13 +2327,12 @@ scm_istr2bve (SCM str)
SCM res = vec;
scm_t_uint32 mask;
size_t k, j;
const char *c_str;
size_t k, j, p;
scm_t_uint32 *data;
data = scm_bitvector_writable_elements (vec, &handle, NULL, NULL, NULL);
c_str = scm_i_string_chars (str);
p = 0;
for (k = 0; k < (len + 31) / 32; k++)
{
data[k] = 0L;
@ -2343,7 +2340,7 @@ scm_istr2bve (SCM str)
if (j > 32)
j = 32;
for (mask = 1L; j--; mask <<= 1)
switch (*c_str++)
switch (scm_i_string_ref (str, p++))
{
case '0':
break;