[gnome-games/wip/exalm/cache2: 19/28] genre: Use string array instead of list



commit 994857920da90ec02253add95a2cde8909d23f49
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Oct 7 22:50:52 2018 +0500

    genre: Use string array instead of list
    
    Genres are never modified in runtime, so it doesn't make sense to use
    lists here.

 src/core/genre.vala            |  2 +-
 src/dummy/dummy-genre.vala     |  6 +++---
 src/generic/generic-genre.vala |  6 +++---
 src/grilo/grilo-genre.vala     | 14 +++++++-------
 4 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/src/core/genre.vala b/src/core/genre.vala
index a806e1cd..84a0be86 100644
--- a/src/core/genre.vala
+++ b/src/core/genre.vala
@@ -3,5 +3,5 @@
 public interface Games.Genre : Object {
        public abstract bool has_loaded { get; protected set; }
 
-       public abstract unowned List<string> get_genre ();
+       public abstract unowned string[] get_genre ();
 }
diff --git a/src/dummy/dummy-genre.vala b/src/dummy/dummy-genre.vala
index 37f8bd1f..97ba1bf4 100644
--- a/src/dummy/dummy-genre.vala
+++ b/src/dummy/dummy-genre.vala
@@ -2,15 +2,15 @@
 
 public class Games.DummyGenre : Object, Genre {
        // This is needed because get_genre() can't transfer ownership of the list.
-       private List<string> genres;
+       private string[] genres;
 
        public bool has_loaded { get; protected set; }
 
        construct {
-               genres = new List<string> ();
+               genres = {};
        }
 
-       public unowned List<string> get_genre () {
+       public unowned string[] get_genre () {
                return genres;
        }
 }
diff --git a/src/generic/generic-genre.vala b/src/generic/generic-genre.vala
index 41ce46f2..d66fa0a6 100644
--- a/src/generic/generic-genre.vala
+++ b/src/generic/generic-genre.vala
@@ -1,7 +1,7 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 public class Games.GenericGenre : Object, Genre {
-       private List<string> genre;
+       private string[] genre;
 
        public bool has_loaded { get; protected set; }
 
@@ -9,11 +9,11 @@ public class Games.GenericGenre : Object, Genre {
                has_loaded = true;
        }
 
-       public GenericGenre (List<string> genre) {
+       public GenericGenre (string[] genre) {
                this.genre = genre.copy ();
        }
 
-       public unowned List<string> get_genre () {
+       public unowned string[] get_genre () {
                return genre;
        }
 }
diff --git a/src/grilo/grilo-genre.vala b/src/grilo/grilo-genre.vala
index 0894e11c..13d113aa 100644
--- a/src/grilo/grilo-genre.vala
+++ b/src/grilo/grilo-genre.vala
@@ -2,7 +2,7 @@
 
 public class Games.GriloGenre : Object, Genre {
        private GriloMedia media;
-       private List<string> genre;
+       private string[] genre;
        private bool resolving;
 
        public bool has_loaded { get; protected set; }
@@ -13,7 +13,7 @@ public class Games.GriloGenre : Object, Genre {
                resolving = false;
        }
 
-       public unowned List<string> get_genre () {
+       public unowned string[] get_genre () {
                if (resolving)
                        return genre;
 
@@ -37,16 +37,16 @@ public class Games.GriloGenre : Object, Genre {
                if (genre_count == 0)
                        return;
 
-               var genre_list = new List<string> ();
+               string[] genres = {};
 
                for (uint index = 0; index < genre_count; index++)
-                       genre_list.append (grl_media.get_genre_nth (index));
+                       genres += grl_media.get_genre_nth (index);
 
-               load_media_genre (genre_list);
+               load_media_genre (genres);
        }
 
-       private void load_media_genre (List<string> genre_list) {
-               genre = genre_list.copy ();
+       private void load_media_genre (string[] genres) {
+               genre = genres.copy ();
 
                has_loaded = true;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]