mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* hash.c: do not allocate st_table when it is not necessary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									5f81a53fd2
								
							
						
					
					
						commit
						e8a1874c19
					
				
					 2 changed files with 25 additions and 17 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,7 @@
 | 
			
		|||
Sat Mar 31 14:16:02 2012  Sokolov Yura (funny-falcon)  <funny.falcon@gmail.com>
 | 
			
		||||
 | 
			
		||||
	* hash.c: do not allocate st_table when it is not necessary.
 | 
			
		||||
 | 
			
		||||
Sat Mar 31 13:42:39 2012  Shugo Maeda  <shugo@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* lib/net/ftp.rb (read_timeout=, open_timeout=): supported timeout.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										38
									
								
								hash.c
									
										
									
									
									
								
							
							
						
						
									
										38
									
								
								hash.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -649,7 +649,7 @@ rb_hash_default(int argc, VALUE *argv, VALUE hash)
 | 
			
		|||
static VALUE
 | 
			
		||||
rb_hash_set_default(VALUE hash, VALUE ifnone)
 | 
			
		||||
{
 | 
			
		||||
    rb_hash_modify(hash);
 | 
			
		||||
    rb_hash_modify_check(hash);
 | 
			
		||||
    RHASH_IFNONE(hash) = ifnone;
 | 
			
		||||
    FL_UNSET(hash, HASH_PROC_DEFAULT);
 | 
			
		||||
    return ifnone;
 | 
			
		||||
| 
						 | 
				
			
			@ -697,7 +697,7 @@ rb_hash_set_default_proc(VALUE hash, VALUE proc)
 | 
			
		|||
{
 | 
			
		||||
    VALUE b;
 | 
			
		||||
 | 
			
		||||
    rb_hash_modify(hash);
 | 
			
		||||
    rb_hash_modify_check(hash);
 | 
			
		||||
    b = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
 | 
			
		||||
    if (NIL_P(b) || !rb_obj_is_proc(b)) {
 | 
			
		||||
	rb_raise(rb_eTypeError,
 | 
			
		||||
| 
						 | 
				
			
			@ -799,7 +799,7 @@ rb_hash_delete(VALUE hash, VALUE key)
 | 
			
		|||
{
 | 
			
		||||
    VALUE val;
 | 
			
		||||
 | 
			
		||||
    rb_hash_modify(hash);
 | 
			
		||||
    rb_hash_modify_check(hash);
 | 
			
		||||
    val = rb_hash_delete_key(hash, key);
 | 
			
		||||
    if (val != Qundef) return val;
 | 
			
		||||
    if (rb_block_given_p()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -852,18 +852,20 @@ rb_hash_shift(VALUE hash)
 | 
			
		|||
{
 | 
			
		||||
    struct shift_var var;
 | 
			
		||||
 | 
			
		||||
    rb_hash_modify(hash);
 | 
			
		||||
    var.key = Qundef;
 | 
			
		||||
    rb_hash_foreach(hash, RHASH(hash)->iter_lev > 0 ? shift_i_safe : shift_i,
 | 
			
		||||
		    (VALUE)&var);
 | 
			
		||||
    rb_hash_modify_check(hash);
 | 
			
		||||
    if (RHASH(hash)->ntbl) {
 | 
			
		||||
	var.key = Qundef;
 | 
			
		||||
	rb_hash_foreach(hash, RHASH(hash)->iter_lev > 0 ? shift_i_safe : shift_i,
 | 
			
		||||
			(VALUE)&var);
 | 
			
		||||
 | 
			
		||||
    if (var.key != Qundef) {
 | 
			
		||||
	if (RHASH(hash)->iter_lev > 0) {
 | 
			
		||||
	    rb_hash_delete_key(hash, var.key);
 | 
			
		||||
	if (var.key != Qundef) {
 | 
			
		||||
	    if (RHASH(hash)->iter_lev > 0) {
 | 
			
		||||
		rb_hash_delete_key(hash, var.key);
 | 
			
		||||
	    }
 | 
			
		||||
	    return rb_assoc_new(var.key, var.val);
 | 
			
		||||
	}
 | 
			
		||||
	return rb_assoc_new(var.key, var.val);
 | 
			
		||||
    }
 | 
			
		||||
    else if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
 | 
			
		||||
    if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
 | 
			
		||||
	return rb_funcall(RHASH_IFNONE(hash), id_yield, 2, hash, Qnil);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
| 
						 | 
				
			
			@ -899,8 +901,9 @@ VALUE
 | 
			
		|||
rb_hash_delete_if(VALUE hash)
 | 
			
		||||
{
 | 
			
		||||
    RETURN_ENUMERATOR(hash, 0, 0);
 | 
			
		||||
    rb_hash_modify(hash);
 | 
			
		||||
    rb_hash_foreach(hash, delete_if_i, hash);
 | 
			
		||||
    rb_hash_modify_check(hash);
 | 
			
		||||
    if (RHASH(hash)->ntbl)
 | 
			
		||||
	rb_hash_foreach(hash, delete_if_i, hash);
 | 
			
		||||
    return hash;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1025,7 +1028,7 @@ rb_hash_select_bang(VALUE hash)
 | 
			
		|||
    st_index_t n;
 | 
			
		||||
 | 
			
		||||
    RETURN_ENUMERATOR(hash, 0, 0);
 | 
			
		||||
    rb_hash_modify(hash);
 | 
			
		||||
    rb_hash_modify_check(hash);
 | 
			
		||||
    if (!RHASH(hash)->ntbl)
 | 
			
		||||
        return Qnil;
 | 
			
		||||
    n = RHASH(hash)->ntbl->num_entries;
 | 
			
		||||
| 
						 | 
				
			
			@ -1050,8 +1053,9 @@ VALUE
 | 
			
		|||
rb_hash_keep_if(VALUE hash)
 | 
			
		||||
{
 | 
			
		||||
    RETURN_ENUMERATOR(hash, 0, 0);
 | 
			
		||||
    rb_hash_modify(hash);
 | 
			
		||||
    rb_hash_foreach(hash, keep_if_i, hash);
 | 
			
		||||
    rb_hash_modify_check(hash);
 | 
			
		||||
    if (RHASH(hash)->ntbl)
 | 
			
		||||
	rb_hash_foreach(hash, keep_if_i, hash);
 | 
			
		||||
    return hash;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue