[gnome-games] savestate: Sort by path instead of creation date
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] savestate: Sort by path instead of creation date
- Date: Fri, 16 Aug 2019 13:18:31 +0000 (UTC)
commit 3bb5ec015b89e1e8de24656c81c4d7caf3713fb7
Author: Yetizone <andreii lisita gmail com>
Date: Fri Aug 16 13:11:06 2019 +0300
savestate: Sort by path instead of creation date
src/core/savestate.vala | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/src/core/savestate.vala b/src/core/savestate.vala
index 711684e7..fe1e98a4 100644
--- a/src/core/savestate.vala
+++ b/src/core/savestate.vala
@@ -258,24 +258,20 @@ public class Games.Savestate : Object {
}
// Sort the savestates array by creation dates
- qsort_with_data (game_savestates, sizeof (Savestate), compare_savestates_creation_date);
+ qsort_with_data (game_savestates, sizeof (Savestate), compare_savestates_path);
return game_savestates;
}
- private static int compare_savestates_creation_date (Savestate s1, Savestate s2) {
- // We want the savestates with the latest creation dates to be the first in the array
- var s1_creation_date_str = s1.get_creation_date ().to_string ();
- var s2_creation_date_str = s2.get_creation_date ().to_string ();
+ private static int compare_savestates_path (Savestate s1, Savestate s2) {
+ if (s1.path < s2.path)
+ return 1;
- if (s1_creation_date_str > s2_creation_date_str)
- return -1;
-
- if (s1_creation_date_str == s2_creation_date_str)
+ if (s1.path == s2.path)
return 0;
- // s1_creation_date_str < s2_creation_date_str
- return 1;
+ // s1.path > s2.path
+ return -1;
}
public static Savestate create_empty_in_tmp (Platform platform) throws Error {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]