mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	st.c: remove equality checks
* st.c (st_update): remove equality checks, callers should ensure the equality, otherwise the behavior is undefined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									ea74da0c6c
								
							
						
					
					
						commit
						783b3c8d5a
					
				
					 2 changed files with 3 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -115,6 +115,9 @@ int st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t));
 | 
			
		|||
int st_lookup(st_table *, st_data_t, st_data_t *);
 | 
			
		||||
int st_get_key(st_table *, st_data_t, st_data_t *);
 | 
			
		||||
typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing);
 | 
			
		||||
/* *key may be altered, but must equal to the old key, i.e., the
 | 
			
		||||
 * results of hash() are same and compare() returns 0, otherwise the
 | 
			
		||||
 * behavior is undefined */
 | 
			
		||||
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
 | 
			
		||||
int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
 | 
			
		||||
int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								st.c
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								st.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -843,16 +843,10 @@ st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data
 | 
			
		|||
	    switch (retval) {
 | 
			
		||||
	      case ST_CONTINUE:
 | 
			
		||||
		if (!existing) {
 | 
			
		||||
		    if (key != old_key) hash_val = do_hash(key, table);
 | 
			
		||||
		    add_packed_direct(table, key, value, hash_val);
 | 
			
		||||
		    break;
 | 
			
		||||
		}
 | 
			
		||||
		if (old_key != PKEY(table, i)) return -1;
 | 
			
		||||
		if (old_key != key) {
 | 
			
		||||
		    if (do_hash(key, table) != hash_val &&
 | 
			
		||||
			!EQUAL(table, key, old_key)) {
 | 
			
		||||
			return -1;
 | 
			
		||||
		    }
 | 
			
		||||
		    PKEY(table, i) = key;
 | 
			
		||||
		}
 | 
			
		||||
		PVAL_SET(table, i, value);
 | 
			
		||||
| 
						 | 
				
			
			@ -879,16 +873,10 @@ st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data
 | 
			
		|||
	switch (retval) {
 | 
			
		||||
	  case ST_CONTINUE:
 | 
			
		||||
	    if (!existing) {
 | 
			
		||||
		if (key != old_key) hash_val = do_hash(key, table);
 | 
			
		||||
		add_direct(table, key, value, hash_val, hash_pos(hash_val, table->num_bins));
 | 
			
		||||
		break;
 | 
			
		||||
	    }
 | 
			
		||||
	    if (old_key != ptr->key) return -1;
 | 
			
		||||
	    if (old_key != key) {
 | 
			
		||||
		if (do_hash(key, table) != hash_val &&
 | 
			
		||||
		    !EQUAL(table, key, old_key)) {
 | 
			
		||||
		    return -1;
 | 
			
		||||
		}
 | 
			
		||||
		ptr->key = key;
 | 
			
		||||
	    }
 | 
			
		||||
	    ptr->record = value;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue