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
91c75a13
Commit
91c75a13
authored
Apr 03, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/icu/Collate: pass std::string_view
parent
e620677d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
13 deletions
+17
-13
Directory.cxx
src/db/plugins/simple/Directory.cxx
+1
-1
SongSort.cxx
src/db/plugins/simple/SongSort.cxx
+1
-1
Collate.cxx
src/lib/icu/Collate.cxx
+11
-9
Collate.hxx
src/lib/icu/Collate.hxx
+4
-2
No files found.
src/db/plugins/simple/Directory.cxx
View file @
91c75a13
...
...
@@ -199,7 +199,7 @@ gcc_pure
static
bool
directory_cmp
(
const
Directory
&
a
,
const
Directory
&
b
)
noexcept
{
return
IcuCollate
(
a
.
path
.
c_str
(),
b
.
path
.
c_str
()
)
<
0
;
return
IcuCollate
(
a
.
path
,
b
.
path
)
<
0
;
}
void
...
...
src/db/plugins/simple/SongSort.cxx
View file @
91c75a13
...
...
@@ -96,7 +96,7 @@ song_cmp(const Song &a, const Song &b) noexcept
return
ret
<
0
;
/* still no difference? compare file name */
return
IcuCollate
(
a
.
filename
.
c_str
(),
b
.
filename
.
c_str
()
)
<
0
;
return
IcuCollate
(
a
.
filename
,
b
.
filename
)
<
0
;
}
void
...
...
src/lib/icu/Collate.cxx
View file @
91c75a13
...
...
@@ -29,6 +29,11 @@
#include <unicode/ustring.h>
#else
#include <algorithm>
#ifndef _WIN32
#include <string>
#endif
#endif
#ifdef _WIN32
...
...
@@ -73,19 +78,14 @@ IcuCollateFinish() noexcept
gcc_pure
int
IcuCollate
(
const
char
*
a
,
const
char
*
b
)
noexcept
IcuCollate
(
std
::
string_view
a
,
std
::
string_view
b
)
noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert
(
a
!=
nullptr
);
assert
(
b
!=
nullptr
);
#endif
#ifdef HAVE_ICU
assert
(
collator
!=
nullptr
);
UErrorCode
code
=
U_ZERO_ERROR
;
return
(
int
)
ucol_strcollUTF8
(
collator
,
a
,
-
1
,
b
,
-
1
,
&
code
);
return
(
int
)
ucol_strcollUTF8
(
collator
,
a
.
data
(),
a
.
size
(),
b
.
data
(),
b
.
size
(),
&
code
);
#elif defined(_WIN32)
AllocatedString
<
wchar_t
>
wa
=
nullptr
,
wb
=
nullptr
;
...
...
@@ -120,6 +120,8 @@ IcuCollate(const char *a, const char *b) noexcept
return
result
;
#else
return
strcoll
(
a
,
b
);
/* need to duplicate for the fallback because std::string_view
is not null-terminated */
return
strcoll
(
std
::
string
(
a
).
c_str
(),
std
::
string
(
b
).
c_str
());
#endif
}
src/lib/icu/Collate.hxx
View file @
91c75a13
...
...
@@ -22,6 +22,8 @@
#include "util/Compiler.h"
#include <string_view>
/**
* Throws #std::runtime_error on error.
*/
...
...
@@ -31,8 +33,8 @@ IcuCollateInit();
void
IcuCollateFinish
()
noexcept
;
gcc_pure
gcc_nonnull_all
gcc_pure
int
IcuCollate
(
const
char
*
a
,
const
char
*
b
)
noexcept
;
IcuCollate
(
std
::
string_view
a
,
std
::
string_view
b
)
noexcept
;
#endif
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