From 8dca38e979bb00f2045bea02f19d407fafd62ca3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 5 Sep 2013 19:08:22 +0200 Subject: Tag: remove the obsolete "bulk" mode Methods BeginAdd() and EndAdd() have been replaced by class TagBuilder. --- src/tag/Tag.cxx | 77 +++------------------------------------------------------ src/tag/Tag.hxx | 14 ----------- 2 files changed, 3 insertions(+), 88 deletions(-) (limited to 'src/tag') diff --git a/src/tag/Tag.cxx b/src/tag/Tag.cxx index 24f3ea1e9..8e6766f80 100644 --- a/src/tag/Tag.cxx +++ b/src/tag/Tag.cxx @@ -27,19 +27,6 @@ #include #include -/** - * Maximum number of items managed in the bulk list; if it is - * exceeded, we switch back to "normal" reallocation. - */ -#define BULK_MAX 64 - -static struct { -#ifndef NDEBUG - bool busy; -#endif - TagItem *items[BULK_MAX]; -} bulk; - enum tag_type tag_name_parse(const char *name) { @@ -87,14 +74,7 @@ Tag::Clear() tag_pool_put_item(items[i]); tag_pool_lock.unlock(); - if (items == bulk.items) { -#ifndef NDEBUG - assert(bulk.busy); - bulk.busy = false; -#endif - } else - g_free(items); - + g_free(items); items = nullptr; num_items = 0; } @@ -106,13 +86,7 @@ Tag::~Tag() tag_pool_put_item(items[i]); tag_pool_lock.unlock(); - if (items == bulk.items) { -#ifndef NDEBUG - assert(bulk.busy); - bulk.busy = false; -#endif - } else - g_free(items); + g_free(items); } Tag::Tag(const Tag &other) @@ -209,40 +183,6 @@ Tag::HasType(tag_type type) const return GetValue(type) != nullptr; } -void -Tag::BeginAdd() -{ - assert(!bulk.busy); - assert(items == nullptr); - assert(num_items == 0); - -#ifndef NDEBUG - bulk.busy = true; -#endif - items = bulk.items; -} - -void -Tag::EndAdd() -{ - if (items == bulk.items) { - assert(num_items <= BULK_MAX); - - if (num_items > 0) { - /* copy the tag items from the bulk list over - to a new list (which fits exactly) */ - items = (TagItem **) - g_malloc(items_size(*this)); - memcpy(items, bulk.items, items_size(*this)); - } else - items = nullptr; - } - -#ifndef NDEBUG - bulk.busy = false; -#endif -} - void Tag::AddItemInternal(tag_type type, const char *value, size_t len) { @@ -256,18 +196,7 @@ Tag::AddItemInternal(tag_type type, const char *value, size_t len) num_items++; - if (items != bulk.items) - /* bulk mode disabled */ - items = (TagItem **) - g_realloc(items, items_size(*this)); - else if (num_items >= BULK_MAX) { - /* bulk list already full - switch back to non-bulk */ - assert(bulk.busy); - - items = (TagItem **)g_malloc(items_size(*this)); - memcpy(items, bulk.items, - items_size(*this) - sizeof(TagItem *)); - } + items = (TagItem **)g_realloc(items, items_size(*this)); tag_pool_lock.lock(); items[i] = tag_pool_get_item(type, value, len); diff --git a/src/tag/Tag.hxx b/src/tag/Tag.hxx index bfbebe671..731d7cd58 100644 --- a/src/tag/Tag.hxx +++ b/src/tag/Tag.hxx @@ -103,20 +103,6 @@ struct Tag { */ void Clear(); - /** - * Gives an optional hint to the tag library that we will now - * add several tag items; this is used by the library to - * optimize memory allocation. Only one tag may be in this - * state, and this tag must not have any items yet. You must - * call tag_end_add() when you are done. - */ - void BeginAdd(); - - /** - * Finishes the operation started with tag_begin_add(). - */ - void EndAdd(); - /** * Appends a new tag item. * -- cgit v1.2.3