diff mbox

libiberty: Don't update and remove did_subs field from demangler structs.

Message ID 1480802098-3015-1-git-send-email-mark@klomp.org
State New
Headers show

Commit Message

Mark Wielaard Dec. 3, 2016, 9:54 p.m. UTC
The d_info field did_subs was used for estimating the string output
size. It was no longer used when the malloc-less callback interface
was introduced in 2007 (svn r121305). But the field was still updated.
When backtracking was introduced in 2013 (svn r205292) did_subs was
also added to the d_info_checkpoint struct. But except for updating
the field it was still not used.

Since it is never used just stop updating the field and remove it
from the two structs.

libiberty/ChangeLog:

	* cp-demangle.h (struct d_info): Remove did_subs field.
	* cp-demangle.c (struct d_info_checkpoint): Likewise.
	(d_template_param): Don't update did_subs.
	(d_substitution): Likewise.
	(d_checkpoint): Don't assign did_subs.
	(d_backtrack): Likewise.
	(cplus_demangle_init_info): Don't initialize did_subs.
---
 libiberty/cp-demangle.c | 8 --------
 libiberty/cp-demangle.h | 4 ----
 2 files changed, 12 deletions(-)

Comments

Mark Wielaard April 18, 2017, 8:56 p.m. UTC | #1
Hi,

On Sat, Dec 03, 2016 at 10:54:58PM +0100, Mark Wielaard wrote:
> The d_info field did_subs was used for estimating the string output
> size. It was no longer used when the malloc-less callback interface
> was introduced in 2007 (svn r121305). But the field was still updated.
> When backtracking was introduced in 2013 (svn r205292) did_subs was
> also added to the d_info_checkpoint struct. But except for updating
> the field it was still not used.
> 
> Since it is never used just stop updating the field and remove it
> from the two structs.
> 
> libiberty/ChangeLog:
> 
> 	* cp-demangle.h (struct d_info): Remove did_subs field.
> 	* cp-demangle.c (struct d_info_checkpoint): Likewise.
> 	(d_template_param): Don't update did_subs.
> 	(d_substitution): Likewise.
> 	(d_checkpoint): Don't assign did_subs.
> 	(d_backtrack): Likewise.
> 	(cplus_demangle_init_info): Don't initialize did_subs.

Ping. Does this look OK to commit?

> ---
>  libiberty/cp-demangle.c | 8 --------
>  libiberty/cp-demangle.h | 4 ----
>  2 files changed, 12 deletions(-)
> 
> diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
> index 45663fe..c628dd6 100644
> --- a/libiberty/cp-demangle.c
> +++ b/libiberty/cp-demangle.c
> @@ -317,7 +317,6 @@ struct d_info_checkpoint
>    const char *n;
>    int next_comp;
>    int next_sub;
> -  int did_subs;
>    int expansion;
>  };
>  
> @@ -3062,8 +3061,6 @@ d_template_param (struct d_info *di)
>    if (param < 0)
>      return NULL;
>  
> -  ++di->did_subs;
> -
>    return d_make_template_param (di, param);
>  }
>  
> @@ -3815,8 +3812,6 @@ d_substitution (struct d_info *di, int prefix)
>        if (id >= (unsigned int) di->next_sub)
>  	return NULL;
>  
> -      ++di->did_subs;
> -
>        return di->subs[id];
>      }
>    else
> @@ -3881,7 +3876,6 @@ d_checkpoint (struct d_info *di, struct d_info_checkpoint *checkpoint)
>    checkpoint->n = di->n;
>    checkpoint->next_comp = di->next_comp;
>    checkpoint->next_sub = di->next_sub;
> -  checkpoint->did_subs = di->did_subs;
>    checkpoint->expansion = di->expansion;
>  }
>  
> @@ -3891,7 +3885,6 @@ d_backtrack (struct d_info *di, struct d_info_checkpoint *checkpoint)
>    di->n = checkpoint->n;
>    di->next_comp = checkpoint->next_comp;
>    di->next_sub = checkpoint->next_sub;
> -  di->did_subs = checkpoint->did_subs;
>    di->expansion = checkpoint->expansion;
>  }
>  
> @@ -6106,7 +6099,6 @@ cplus_demangle_init_info (const char *mangled, int options, size_t len,
>       chars in the mangled string.  */
>    di->num_subs = len;
>    di->next_sub = 0;
> -  di->did_subs = 0;
>  
>    di->last_name = NULL;
>  
> diff --git a/libiberty/cp-demangle.h b/libiberty/cp-demangle.h
> index 197883e..f197f99 100644
> --- a/libiberty/cp-demangle.h
> +++ b/libiberty/cp-demangle.h
> @@ -112,10 +112,6 @@ struct d_info
>    int next_sub;
>    /* The number of available entries in the subs array.  */
>    int num_subs;
> -  /* The number of substitutions which we actually made from the subs
> -     array, plus the number of template parameter references we
> -     saw.  */
> -  int did_subs;
>    /* The last name we saw, for constructors and destructors.  */
>    struct demangle_component *last_name;
>    /* A running total of the length of large expansions from the
> -- 
> 1.8.3.1
Li, Pan2 via Gcc-patches April 18, 2017, 8:58 p.m. UTC | #2
On Tue, Apr 18, 2017 at 1:56 PM, Mark Wielaard <mark@klomp.org> wrote:
>
> On Sat, Dec 03, 2016 at 10:54:58PM +0100, Mark Wielaard wrote:
>> The d_info field did_subs was used for estimating the string output
>> size. It was no longer used when the malloc-less callback interface
>> was introduced in 2007 (svn r121305). But the field was still updated.
>> When backtracking was introduced in 2013 (svn r205292) did_subs was
>> also added to the d_info_checkpoint struct. But except for updating
>> the field it was still not used.
>>
>> Since it is never used just stop updating the field and remove it
>> from the two structs.
>>
>> libiberty/ChangeLog:
>>
>>       * cp-demangle.h (struct d_info): Remove did_subs field.
>>       * cp-demangle.c (struct d_info_checkpoint): Likewise.
>>       (d_template_param): Don't update did_subs.
>>       (d_substitution): Likewise.
>>       (d_checkpoint): Don't assign did_subs.
>>       (d_backtrack): Likewise.
>>       (cplus_demangle_init_info): Don't initialize did_subs.
>
> Ping. Does this look OK to commit?

This is fine when we are back in stage 1.

Thanks.

Ian
diff mbox

Patch

diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 45663fe..c628dd6 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -317,7 +317,6 @@  struct d_info_checkpoint
   const char *n;
   int next_comp;
   int next_sub;
-  int did_subs;
   int expansion;
 };
 
@@ -3062,8 +3061,6 @@  d_template_param (struct d_info *di)
   if (param < 0)
     return NULL;
 
-  ++di->did_subs;
-
   return d_make_template_param (di, param);
 }
 
@@ -3815,8 +3812,6 @@  d_substitution (struct d_info *di, int prefix)
       if (id >= (unsigned int) di->next_sub)
 	return NULL;
 
-      ++di->did_subs;
-
       return di->subs[id];
     }
   else
@@ -3881,7 +3876,6 @@  d_checkpoint (struct d_info *di, struct d_info_checkpoint *checkpoint)
   checkpoint->n = di->n;
   checkpoint->next_comp = di->next_comp;
   checkpoint->next_sub = di->next_sub;
-  checkpoint->did_subs = di->did_subs;
   checkpoint->expansion = di->expansion;
 }
 
@@ -3891,7 +3885,6 @@  d_backtrack (struct d_info *di, struct d_info_checkpoint *checkpoint)
   di->n = checkpoint->n;
   di->next_comp = checkpoint->next_comp;
   di->next_sub = checkpoint->next_sub;
-  di->did_subs = checkpoint->did_subs;
   di->expansion = checkpoint->expansion;
 }
 
@@ -6106,7 +6099,6 @@  cplus_demangle_init_info (const char *mangled, int options, size_t len,
      chars in the mangled string.  */
   di->num_subs = len;
   di->next_sub = 0;
-  di->did_subs = 0;
 
   di->last_name = NULL;
 
diff --git a/libiberty/cp-demangle.h b/libiberty/cp-demangle.h
index 197883e..f197f99 100644
--- a/libiberty/cp-demangle.h
+++ b/libiberty/cp-demangle.h
@@ -112,10 +112,6 @@  struct d_info
   int next_sub;
   /* The number of available entries in the subs array.  */
   int num_subs;
-  /* The number of substitutions which we actually made from the subs
-     array, plus the number of template parameter references we
-     saw.  */
-  int did_subs;
   /* The last name we saw, for constructors and destructors.  */
   struct demangle_component *last_name;
   /* A running total of the length of large expansions from the