mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	string.c: reduce objects in rb_fstring
* string.c (rb_fstring, rb_str_free): use st_data_t instead of VALUE. * string.c (rb_fstring): get rid of duplicating already frozen object. * parse.y (str_suffix_gen): freeze in advance to reduce objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									f0bc5b1c9f
								
							
						
					
					
						commit
						dffae9a1f9
					
				
					 3 changed files with 20 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,11 @@
 | 
			
		|||
Thu Sep  5 17:25:49 2013  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* string.c (rb_fstring, rb_str_free): use st_data_t instead of VALUE.
 | 
			
		||||
 | 
			
		||||
	* string.c (rb_fstring): get rid of duplicating already frozen object.
 | 
			
		||||
 | 
			
		||||
	* parse.y (str_suffix_gen): freeze in advance to reduce objects.
 | 
			
		||||
 | 
			
		||||
Thu Sep  5 14:01:22 2013  Eric Hodel  <drbrain@segment7.net>
 | 
			
		||||
 | 
			
		||||
	* lib/optparse.rb:  The Integer acceptable now allows binary and
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								parse.y
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								parse.y
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -8561,6 +8561,7 @@ str_suffix_gen(struct parser_params *parser, NODE *node, long opt)
 | 
			
		|||
#endif
 | 
			
		||||
#if STR_OPTION_FROZEN
 | 
			
		||||
	if (opt & STR_OPTION_FROZEN) {
 | 
			
		||||
	    OBJ_FREEZE(node->nd_lit);
 | 
			
		||||
	    node->nd_lit = rb_fstring(node->nd_lit);
 | 
			
		||||
	    nd_set_type(node, NODE_LIT);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										19
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								string.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -141,14 +141,16 @@ static const struct st_hash_type fstring_hash_type = {
 | 
			
		|||
VALUE
 | 
			
		||||
rb_fstring(VALUE str)
 | 
			
		||||
{
 | 
			
		||||
    VALUE fstr;
 | 
			
		||||
    if (!st_lookup(frozen_strings, (st_data_t)str, (st_data_t*)&fstr)) {
 | 
			
		||||
	fstr = rb_str_dup(str);
 | 
			
		||||
	OBJ_FREEZE(fstr);
 | 
			
		||||
	RBASIC(fstr)->flags |= RSTRING_FSTR;
 | 
			
		||||
	st_insert(frozen_strings, fstr, fstr);
 | 
			
		||||
    st_data_t fstr;
 | 
			
		||||
    if (st_lookup(frozen_strings, (st_data_t)str, &fstr)) {
 | 
			
		||||
	str = (VALUE)fstr;
 | 
			
		||||
    }
 | 
			
		||||
    return fstr;
 | 
			
		||||
    else {
 | 
			
		||||
	str = rb_str_new_frozen(str);
 | 
			
		||||
	RBASIC(str)->flags |= RSTRING_FSTR;
 | 
			
		||||
	st_insert(frozen_strings, str, str);
 | 
			
		||||
    }
 | 
			
		||||
    return str;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline int
 | 
			
		||||
| 
						 | 
				
			
			@ -859,7 +861,8 @@ void
 | 
			
		|||
rb_str_free(VALUE str)
 | 
			
		||||
{
 | 
			
		||||
    if (FL_TEST(str, RSTRING_FSTR)) {
 | 
			
		||||
	st_delete(frozen_strings, (st_data_t*)&str, NULL);
 | 
			
		||||
	st_data_t fstr = (st_data_t)str;
 | 
			
		||||
	st_delete(frozen_strings, &fstr, NULL);
 | 
			
		||||
    }
 | 
			
		||||
    if (!STR_EMBED_P(str) && !STR_SHARED_P(str)) {
 | 
			
		||||
	xfree(RSTRING(str)->as.heap.ptr);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue