From b17004b8068310facd08d4dd15aff09dbaee8b63 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Mon, 9 Oct 2000 12:39:14 +0000 Subject: [PATCH] * Eliminate last call to scm_vector_set_length_x within libguile. --- libguile/ChangeLog | 8 ++++++++ libguile/print.c | 25 +++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 3a724bda7..52a1cf7c8 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,11 @@ +2000-10-09 Dirk Herrmann + + * print.c (make_print_state, scm_iprin1): Replace SCM_LENGTH with + the appropriate SCM__LENGTH macro. + + (grow_ref_stack): Don't call scm_vector_set_length_x to resize + the print stack. + 2000-10-09 Dirk Herrmann * numbers.c (big2str): Avoid redundant copying. diff --git a/libguile/print.c b/libguile/print.c index 499f44760..9bd447815 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -215,7 +215,7 @@ make_print_state (void) pstate->ref_vect = scm_make_vector (SCM_MAKINUM (PSTATE_SIZE), SCM_UNDEFINED); pstate->ref_stack = SCM_VELTS (pstate->ref_vect); - pstate->ceiling = SCM_LENGTH (pstate->ref_vect); + pstate->ceiling = SCM_VECTOR_LENGTH (pstate->ref_vect); return print_state; } @@ -259,9 +259,18 @@ scm_free_print_state (SCM print_state) static void grow_ref_stack (scm_print_state *pstate) { - int new_size = 2 * pstate->ceiling; - scm_vector_set_length_x (pstate->ref_vect, SCM_MAKINUM (new_size)); - pstate->ref_stack = SCM_VELTS (pstate->ref_vect); + unsigned long int old_size = SCM_VECTOR_LENGTH (pstate->ref_vect); + SCM *old_elts = SCM_VELTS (pstate->ref_vect); + unsigned long int new_size = 2 * pstate->ceiling; + SCM new_vect = scm_make_vector (new_size, SCM_UNDEFINED); + SCM *new_elts = SCM_VELTS (new_vect); + unsigned long int i; + + for (i = 0; i != old_size; ++i) + new_elts [i] = old_elts [i]; + + pstate->ref_vect = new_vect; + pstate->ref_stack = new_elts; pstate->ceiling = new_size; } @@ -494,7 +503,7 @@ taloop: int maybe_weird; int mw_pos = 0; - len = SCM_LENGTH (exp); + len = SCM_SYMBOL_LENGTH (exp); str = SCM_SYMBOL_CHARS (exp); scm_remember (&exp); pos = 0; @@ -577,9 +586,9 @@ taloop: common_vector_printer: { register long i; - int last = SCM_LENGTH (exp) - 1; + int last = SCM_VECTOR_LENGTH (exp) - 1; int cutp = 0; - if (pstate->fancyp && SCM_LENGTH (exp) > pstate->length) + if (pstate->fancyp && SCM_VECTOR_LENGTH (exp) > pstate->length) { last = pstate->length - 1; cutp = 1; @@ -662,7 +671,7 @@ taloop: break; case scm_tc7_contin: scm_puts ("#', port); -- 2.20.1