mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	cmp_clamp: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
This commit is contained in:
		
							parent
							
								
									3a3728e4b3
								
							
						
					
					
						commit
						a93da4970b
					
				
				
				Notes:
				
					git
				
				2020-06-29 11:07:13 +09:00 
				
			
			
			
		
		
					 1 changed files with 1 additions and 3 deletions
				
			
		
							
								
								
									
										4
									
								
								compar.c
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								compar.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -233,11 +233,9 @@ cmp_clamp(int argc, VALUE *argv, VALUE x)
 | 
			
		|||
        }
 | 
			
		||||
        if (!NIL_P(max)) {
 | 
			
		||||
            if (excl) rb_raise(rb_eArgError, "cannot clamp with an exclusive range");
 | 
			
		||||
            if (!NIL_P(min) && cmpint(min, max) > 0) goto arg_error;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if (cmpint(min, max) > 0) {
 | 
			
		||||
      arg_error:
 | 
			
		||||
    if (!NIL_P(min) && !NIL_P(max) && cmpint(min, max) > 0) {
 | 
			
		||||
	rb_raise(rb_eArgError, "min argument must be smaller than max argument");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue