aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2018-12-06 12:02:55 +0000
committerFurkan Sahin <furkan-dev@proton.me>2018-12-06 12:02:55 +0000
commit5debd8a4d6015fb9bfd4099d38d2e6037520921c (patch)
tree7060296a2c79f98488d865ad72feba4bb508bf3f /common
parent5ed6e811f36563f2f502a634239b3bfd4ce05454 (diff)
list: double list capacity when resizing instead of incrementing
This is the industry standard since it allows insertion to be amortized O(1) time.
Diffstat (limited to 'common')
-rw-r--r--common/list.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/common/list.c b/common/list.c
index ee268c9a..66cf133b 100644
--- a/common/list.c
+++ b/common/list.c
@@ -17,7 +17,7 @@ list_t *create_list(void) {
static void list_resize(list_t *list) {
if (list->length == list->capacity) {
- list->capacity += 10;
+ list->capacity *= 2;
list->items = realloc(list->items, sizeof(void*) * list->capacity);
}
}