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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
38 deletions
+51
-38
TagFile.cxx
src/TagFile.cxx
+51
-38
No files found.
src/TagFile.cxx
View file @
c97685fe
...
@@ -29,58 +29,71 @@
...
@@ -29,58 +29,71 @@
#include <assert.h>
#include <assert.h>
bool
class
TagFileScan
{
tag_file_scan
(
Path
path_fs
,
const
Path
path_fs
;
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
const
char
*
const
suffix
;
{
assert
(
!
path_fs
.
IsNull
());
assert
(
handler
!=
nullptr
);
/* check if there's a suffix and a plugin */
const
char
*
suffix
=
uri_get_suffix
(
path_fs
.
c_str
());
if
(
suffix
==
nullptr
)
return
false
;
const
struct
DecoderPlugin
*
plugin
=
const
tag_handler
&
handler
;
decoder_plugin_from_suffix
(
suffix
,
nullptr
);
void
*
handler_ctx
;
if
(
plugin
==
nullptr
)
return
false
;
InputStream
*
is
=
nullptr
;
Mutex
mutex
;
Mutex
mutex
;
Cond
cond
;
Cond
cond
;
InputStream
*
is
;
do
{
public
:
/* load file tag */
TagFileScan
(
Path
_path_fs
,
const
char
*
_suffix
,
if
(
plugin
->
ScanFile
(
path_fs
.
c_str
(),
const
tag_handler
&
_handler
,
void
*
_handler_ctx
)
*
handler
,
handler_ctx
))
:
path_fs
(
_path_fs
),
suffix
(
_suffix
),
break
;
handler
(
_handler
),
handler_ctx
(
_handler_ctx
)
,
is
(
nullptr
)
{}
/* fall back to stream tag */
~
TagFileScan
()
{
if
(
plugin
->
scan_stream
!=
nullptr
)
{
if
(
is
!=
nullptr
)
/* open the InputStream (if not already
is
->
Close
();
open) */
}
if
(
is
==
nullptr
)
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
(),
is
=
InputStream
::
Open
(
path_fs
.
c_str
(),
mutex
,
cond
,
mutex
,
cond
,
IgnoreError
());
IgnoreError
());
if
(
is
==
nullptr
)
return
false
;
}
/* now try the stream_tag() method */
/* now try the stream_tag() method */
if
(
is
!=
nullptr
)
{
return
plugin
.
ScanStream
(
*
is
,
handler
,
handler_ctx
);
if
(
plugin
->
ScanStream
(
*
is
,
*
handler
,
handler_ctx
))
break
;
is
->
LockRewind
(
IgnoreError
());
}
}
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
)
{
assert
(
!
path_fs
.
IsNull
());
assert
(
handler
!=
nullptr
);
plugin
=
decoder_plugin_from_suffix
(
suffix
,
plugin
);
/* check if there's a suffix and a plugin */
}
while
(
plugin
!=
nullptr
);
if
(
is
!=
nullptr
)
const
char
*
suffix
=
uri_get_suffix
(
path_fs
.
c_str
());
is
->
Close
();
if
(
suffix
==
nullptr
)
return
false
;
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