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
affc4466
Commit
affc4466
authored
Jan 08, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Queue: use std::stable_sort() instead of g_qsort_with_data()
parent
255ee646
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
26 deletions
+8
-26
Queue.cxx
src/Queue.cxx
+8
-26
No files found.
src/Queue.cxx
View file @
affc4466
...
@@ -21,8 +21,6 @@
...
@@ -21,8 +21,6 @@
#include "Queue.hxx"
#include "Queue.hxx"
#include "song.h"
#include "song.h"
#include <glib.h>
#include <stdlib.h>
#include <stdlib.h>
queue
::
queue
(
unsigned
_max_length
)
queue
::
queue
(
unsigned
_max_length
)
...
@@ -280,26 +278,6 @@ queue::Clear()
...
@@ -280,26 +278,6 @@ queue::Clear()
length
=
0
;
length
=
0
;
}
}
static
gint
queue_item_compare_order_priority
(
gconstpointer
av
,
gconstpointer
bv
,
gpointer
user_data
)
{
const
struct
queue
*
queue
=
(
const
struct
queue
*
)
user_data
;
const
unsigned
*
const
ap
=
(
const
unsigned
*
)
av
;
const
unsigned
*
const
bp
=
(
const
unsigned
*
)
bv
;
assert
(
ap
>=
queue
->
order
&&
ap
<
queue
->
order
+
queue
->
length
);
assert
(
bp
>=
queue
->
order
&&
bp
<
queue
->
order
+
queue
->
length
);
uint8_t
a
=
queue
->
items
[
*
ap
].
priority
;
uint8_t
b
=
queue
->
items
[
*
bp
].
priority
;
if
(
gcc_likely
(
a
==
b
))
return
0
;
else
if
(
a
>
b
)
return
-
1
;
else
return
1
;
}
static
void
static
void
queue_sort_order_by_priority
(
struct
queue
*
queue
,
unsigned
start
,
unsigned
end
)
queue_sort_order_by_priority
(
struct
queue
*
queue
,
unsigned
start
,
unsigned
end
)
{
{
...
@@ -308,10 +286,14 @@ queue_sort_order_by_priority(struct queue *queue, unsigned start, unsigned end)
...
@@ -308,10 +286,14 @@ queue_sort_order_by_priority(struct queue *queue, unsigned start, unsigned end)
assert
(
start
<=
end
);
assert
(
start
<=
end
);
assert
(
end
<=
queue
->
length
);
assert
(
end
<=
queue
->
length
);
g_qsort_with_data
(
&
queue
->
order
[
start
],
end
-
start
,
auto
cmp
=
[
queue
](
unsigned
a_pos
,
unsigned
b_pos
){
sizeof
(
queue
->
order
[
0
]),
const
queue
::
Item
&
a
=
queue
->
items
[
a_pos
];
queue_item_compare_order_priority
,
const
queue
::
Item
&
b
=
queue
->
items
[
b_pos
];
queue
);
return
a
.
priority
>
b
.
priority
;
};
std
::
stable_sort
(
queue
->
order
+
start
,
queue
->
order
+
end
,
cmp
);
}
}
void
void
...
...
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