mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	button: save a few cycles by returning early
...and in preparation for the merge-config patch, avoid building directory lists for empty filenames.
This commit is contained in:
		
							parent
							
								
									4238d7fc33
								
							
						
					
					
						commit
						d0aff49c81
					
				
					 3 changed files with 9 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -49,6 +49,9 @@ button_png_load(const char *button_name, struct lab_data_buffer **buffer)
 | 
			
		|||
		wlr_buffer_drop(&(*buffer)->base);
 | 
			
		||||
		*buffer = NULL;
 | 
			
		||||
	}
 | 
			
		||||
	if (!button_name || !*button_name) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	char path[4096] = { 0 };
 | 
			
		||||
	button_filename(button_name, path, sizeof(path));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,9 @@ button_svg_load(const char *button_name, struct lab_data_buffer **buffer,
 | 
			
		|||
		wlr_buffer_drop(&(*buffer)->base);
 | 
			
		||||
		*buffer = NULL;
 | 
			
		||||
	}
 | 
			
		||||
	if (!button_name || !*button_name) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	char filename[4096] = { 0 };
 | 
			
		||||
	button_filename(button_name, filename, sizeof(filename));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -279,6 +279,9 @@ button_xbm_load(const char *button_name, struct lab_data_buffer **buffer,
 | 
			
		|||
		wlr_buffer_drop(&(*buffer)->base);
 | 
			
		||||
		*buffer = NULL;
 | 
			
		||||
	}
 | 
			
		||||
	if (!button_name || !*button_name) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	color = argb32(rgba);
 | 
			
		||||
 | 
			
		||||
	/* Read file into memory as it's easier to tokenize that way */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue