This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Reduce memory required by build_string


.. by using the space provided by tail-padding instead of simply
adding the required length to sizeof (struct tree_string).

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for mainline?

Thanks,
Richard.

:ADDPATCH middle-end:

2006-06-26  Richard Guenther  <rguenther@suse.de>

	* tree.c (build_string): Do not waste tail padding in
	struct tree_string.

Index: tree.c
===================================================================
*** tree.c	(revision 115006)
--- tree.c	(working copy)
*************** build_string (int len, const char *str)
*** 1120,1127 ****
  {
    tree s;
    size_t length;
!   
!   length = len + sizeof (struct tree_string);
  
  #ifdef GATHER_STATISTICS
    tree_node_counts[(int) c_kind]++;
--- 1120,1130 ----
  {
    tree s;
    size_t length;
! 
!   /* Do not waste bytes provided by padding of struct tree_string.  */
!   length = ((len + sizeof (struct tree_string))
! 	    & ~(sizeof (struct tree_string)
! 		- offsetof (struct tree_string, str) - 1));
  
  #ifdef GATHER_STATISTICS
    tree_node_counts[(int) c_kind]++;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]