Commit a3afd517 authored by Max Kellermann's avatar Max Kellermann

tag/TagPool: optimize _dup_item()

When a reference counter is at its limit, don't allocate a new TagPoolSlot - that would result in many TagPoolSlot instances with ref==1. This in turn would make the linked list very very large, which means quadratic runtime for many operations.
parent f1285a6d
......@@ -4,6 +4,7 @@ ver 0.19.14 (not yet released)
- opus: limit tag size to 64 kB
* archive
- iso9660: fix buffer overflow
* fix quadratic runtime bug in the tag pool
* fix build failures on non-glibc builds due to constexpr Mutex
ver 0.19.13 (2016/02/23)
......
......@@ -144,14 +144,10 @@ tag_pool_dup_item(TagItem *item)
return item;
} else {
/* the reference counter overflows above MAX_REF;
duplicate the item, and start with 1 */
obtain a reference to a different TagPoolSlot which
isn't yet "full" */
size_t length = strlen(item->value);
auto slot_p = tag_value_slot_p(item->type,
item->value, length);
slot = TagPoolSlot::Create(*slot_p, item->type,
item->value, strlen(item->value));
*slot_p = slot;
return &slot->item;
return tag_pool_get_item(item->type, item->value, length);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment