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
c97685fe
Commit
c97685fe
authored
Dec 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TagFile: use decoder_plugins_try()
.. instead of decoder_plugin_from_suffix(). This reduces overhead by walking the array only once.
parent
358b6710
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
41 deletions
+54
-41
TagFile.cxx
src/TagFile.cxx
+54
-41
No files found.
src/TagFile.cxx
View file @
c97685fe
...
...
@@ -29,6 +29,56 @@
#include <assert.h>
class
TagFileScan
{
const
Path
path_fs
;
const
char
*
const
suffix
;
const
tag_handler
&
handler
;
void
*
handler_ctx
;
Mutex
mutex
;
Cond
cond
;
InputStream
*
is
;
public
:
TagFileScan
(
Path
_path_fs
,
const
char
*
_suffix
,
const
tag_handler
&
_handler
,
void
*
_handler_ctx
)
:
path_fs
(
_path_fs
),
suffix
(
_suffix
),
handler
(
_handler
),
handler_ctx
(
_handler_ctx
)
,
is
(
nullptr
)
{}
~
TagFileScan
()
{
if
(
is
!=
nullptr
)
is
->
Close
();
}
bool
ScanFile
(
const
DecoderPlugin
&
plugin
)
{
return
plugin
.
ScanFile
(
path_fs
.
c_str
(),
handler
,
handler_ctx
);
}
bool
ScanStream
(
const
DecoderPlugin
&
plugin
)
{
if
(
plugin
.
scan_stream
==
nullptr
)
return
false
;
/* open the InputStream (if not already open) */
if
(
is
==
nullptr
)
{
is
=
InputStream
::
Open
(
path_fs
.
c_str
(),
mutex
,
cond
,
IgnoreError
());
if
(
is
==
nullptr
)
return
false
;
}
/* now try the stream_tag() method */
return
plugin
.
ScanStream
(
*
is
,
handler
,
handler_ctx
);
}
bool
Scan
(
const
DecoderPlugin
&
plugin
)
{
return
plugin
.
SupportsSuffix
(
suffix
)
&&
(
ScanFile
(
plugin
)
||
ScanStream
(
plugin
));
}
};
bool
tag_file_scan
(
Path
path_fs
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
...
...
@@ -42,45 +92,8 @@ tag_file_scan(Path path_fs,
if
(
suffix
==
nullptr
)
return
false
;
const
struct
DecoderPlugin
*
plugin
=
decoder_plugin_from_suffix
(
suffix
,
nullptr
);
if
(
plugin
==
nullptr
)
return
false
;
InputStream
*
is
=
nullptr
;
Mutex
mutex
;
Cond
cond
;
do
{
/* load file tag */
if
(
plugin
->
ScanFile
(
path_fs
.
c_str
(),
*
handler
,
handler_ctx
))
break
;
/* fall back to stream tag */
if
(
plugin
->
scan_stream
!=
nullptr
)
{
/* open the InputStream (if not already
open) */
if
(
is
==
nullptr
)
is
=
InputStream
::
Open
(
path_fs
.
c_str
(),
mutex
,
cond
,
IgnoreError
());
/* now try the stream_tag() method */
if
(
is
!=
nullptr
)
{
if
(
plugin
->
ScanStream
(
*
is
,
*
handler
,
handler_ctx
))
break
;
is
->
LockRewind
(
IgnoreError
());
}
}
plugin
=
decoder_plugin_from_suffix
(
suffix
,
plugin
);
}
while
(
plugin
!=
nullptr
);
if
(
is
!=
nullptr
)
is
->
Close
();
return
plugin
!=
nullptr
;
TagFileScan
tfs
(
path_fs
,
suffix
,
*
handler
,
handler_ctx
);
return
decoder_plugins_try
([
&
](
const
DecoderPlugin
&
plugin
){
return
tfs
.
Scan
(
plugin
);
});
}
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