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
ed7baf3a
Commit
ed7baf3a
authored
Oct 13, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/Id3Scan: use StringView::Strip() instead of duplicating the string
parent
1e159af2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
23 deletions
+5
-23
Id3Scan.cxx
src/tag/Id3Scan.cxx
+5
-19
Id3String.hxx
src/tag/Id3String.hxx
+0
-4
No files found.
src/tag/Id3Scan.cxx
View file @
ed7baf3a
...
...
@@ -25,9 +25,6 @@
#include "Builder.hxx"
#include "Tag.hxx"
#include "Id3MusicBrainz.hxx"
#include "util/Alloc.hxx"
#include "util/ScopeExit.hxx"
#include "util/StringStrip.hxx"
#include "util/StringView.hxx"
#include <id3tag.h>
...
...
@@ -78,31 +75,20 @@ tag_id3_getstring(const struct id3_frame *frame, unsigned i) noexcept
return
Id3String
::
FromUCS4
(
ucs4
);
}
/* This will try to convert a string to utf-8,
*/
static
id3_utf8_t
*
import_id3_string
(
const
id3_ucs4_t
*
ucs4
)
{
auto
utf8
=
Id3String
::
FromUCS4
(
ucs4
);
if
(
!
utf8
)
return
nullptr
;
return
(
id3_utf8_t
*
)
xstrdup
(
Strip
(
utf8
.
c_str
()));
}
static
void
InvokeOnTag
(
TagHandler
&
handler
,
TagType
type
,
const
id3_ucs4_t
*
ucs4
)
noexcept
{
assert
(
type
<
TAG_NUM_OF_ITEM_TYPES
);
assert
(
ucs4
!=
nullptr
);
id3_utf8_t
*
utf8
=
import_id3_string
(
ucs4
);
if
(
utf8
==
nullptr
)
const
auto
utf8
=
Id3String
::
FromUCS4
(
ucs4
);
if
(
!
utf8
)
return
;
AtScopeExit
(
utf8
)
{
free
(
utf8
);
};
StringView
s
{
utf8
.
c_str
()};
s
.
Strip
();
handler
.
OnTag
(
type
,
(
const
char
*
)
utf8
);
handler
.
OnTag
(
type
,
s
);
}
/**
...
...
src/tag/Id3String.hxx
View file @
ed7baf3a
...
...
@@ -49,10 +49,6 @@ public:
return
p
!=
nullptr
;
}
char
*
c_str
()
noexcept
{
return
(
char
*
)
p
;
}
const
char
*
c_str
()
const
noexcept
{
return
(
const
char
*
)
p
;
}
...
...
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