mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Simplified rb_obj_copy_ivar implementation
This commit is contained in:
		
							parent
							
								
									1865ed4ab9
								
							
						
					
					
						commit
						b54c8ba8fc
					
				
				
				Notes:
				
					git
				
				2022-10-17 21:48:04 +00:00 
				
			
			
			
		
		
					 1 changed files with 9 additions and 25 deletions
				
			
		
							
								
								
									
										34
									
								
								object.c
									
										
									
									
									
								
							
							
						
						
									
										34
									
								
								object.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -268,37 +268,21 @@ rb_obj_singleton_class(VALUE obj)
 | 
			
		|||
MJIT_FUNC_EXPORTED void
 | 
			
		||||
rb_obj_copy_ivar(VALUE dest, VALUE obj)
 | 
			
		||||
{
 | 
			
		||||
    VALUE *dest_buf = ROBJECT_IVPTR(dest);
 | 
			
		||||
    VALUE *src_buf = ROBJECT_IVPTR(obj);
 | 
			
		||||
    uint32_t dest_len = ROBJECT_NUMIV(dest);
 | 
			
		||||
    uint32_t src_len = ROBJECT_NUMIV(obj);
 | 
			
		||||
    uint32_t max_len = dest_len < src_len ? src_len : dest_len;
 | 
			
		||||
 | 
			
		||||
    rb_ensure_iv_list_size(dest, dest_len, max_len);
 | 
			
		||||
 | 
			
		||||
    dest_len = ROBJECT_NUMIV(dest);
 | 
			
		||||
    uint32_t min_len = dest_len > src_len ? src_len : dest_len;
 | 
			
		||||
 | 
			
		||||
    if (RBASIC(obj)->flags & ROBJECT_EMBED) {
 | 
			
		||||
        src_buf = ROBJECT(obj)->as.ary;
 | 
			
		||||
 | 
			
		||||
        // embedded -> embedded
 | 
			
		||||
        if (RBASIC(dest)->flags & ROBJECT_EMBED) {
 | 
			
		||||
            dest_buf = ROBJECT(dest)->as.ary;
 | 
			
		||||
        }
 | 
			
		||||
        // embedded -> extended
 | 
			
		||||
        else {
 | 
			
		||||
            dest_buf = ROBJECT(dest)->as.heap.ivptr;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    // extended -> extended
 | 
			
		||||
    else {
 | 
			
		||||
    if (dest_len < src_len) {
 | 
			
		||||
        rb_ensure_iv_list_size(dest, dest_len, src_len);
 | 
			
		||||
        RUBY_ASSERT(!(RBASIC(dest)->flags & ROBJECT_EMBED));
 | 
			
		||||
        dest_buf = ROBJECT(dest)->as.heap.ivptr;
 | 
			
		||||
        src_buf = ROBJECT(obj)->as.heap.ivptr;
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        RUBY_ASSERT((RBASIC(dest)->flags & ROBJECT_EMBED));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    MEMCPY(dest_buf, src_buf, VALUE, min_len);
 | 
			
		||||
    VALUE * dest_buf = ROBJECT_IVPTR(dest);
 | 
			
		||||
    VALUE * src_buf = ROBJECT_IVPTR(obj);
 | 
			
		||||
 | 
			
		||||
    MEMCPY(dest_buf, src_buf, VALUE, ROBJECT_IV_COUNT(obj));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue