mirror of
				https://github.com/swaywm/sway.git
				synced 2025-10-29 05:40:18 -04:00 
			
		
		
		
	list: double list capacity when resizing instead of incrementing
This is the industry standard since it allows insertion to be amortized O(1) time.
This commit is contained in:
		
							parent
							
								
									cf6edaf26a
								
							
						
					
					
						commit
						bd6a639667
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		|  | @ -17,7 +17,7 @@ list_t *create_list(void) { | ||||||
| 
 | 
 | ||||||
| static void list_resize(list_t *list) { | static void list_resize(list_t *list) { | ||||||
| 	if (list->length == list->capacity) { | 	if (list->length == list->capacity) { | ||||||
| 		list->capacity += 10; | 		list->capacity *= 2; | ||||||
| 		list->items = realloc(list->items, sizeof(void*) * list->capacity); | 		list->items = realloc(list->items, sizeof(void*) * list->capacity); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ian Fan
						Ian Fan