Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
8dca38e9
Commit
8dca38e9
authored
Sep 05, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tag: remove the obsolete "bulk" mode
Methods BeginAdd() and EndAdd() have been replaced by class TagBuilder.
parent
662bed6a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
88 deletions
+3
-88
Tag.cxx
src/tag/Tag.cxx
+3
-74
Tag.hxx
src/tag/Tag.hxx
+0
-14
No files found.
src/tag/Tag.cxx
View file @
8dca38e9
...
...
@@ -27,19 +27,6 @@
#include <assert.h>
#include <string.h>
/**
* 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
)
...
...
@@ -210,40 +184,6 @@ Tag::HasType(tag_type type) const
}
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
)
{
unsigned
int
i
=
num_items
;
...
...
@@ -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
);
...
...
src/tag/Tag.hxx
View file @
8dca38e9
...
...
@@ -104,20 +104,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.
*
* @param type the type of the new tag item
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment