Simplify sorting of posts.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 7 Dec 2014 09:47:59 +0000 (10:47 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 7 Dec 2014 09:53:15 +0000 (10:53 +0100)
src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java

index 6da31fc..44111aa 100644 (file)
@@ -47,6 +47,7 @@ import net.pterodactylus.sone.freenet.wot.OwnIdentity;
 
 import freenet.keys.FreenetURI;
 
+import com.google.common.collect.FluentIterable;
 import com.google.common.hash.Hasher;
 import com.google.common.hash.Hashing;
 
@@ -354,12 +355,9 @@ public class SoneImpl implements LocalSone {
         * @return All posts of this Sone
         */
        public List<Post> getPosts() {
-               List<Post> sortedPosts;
                synchronized (this) {
-                       sortedPosts = new ArrayList<Post>(posts);
+                       return FluentIterable.from(posts).toSortedList(Post.TIME_COMPARATOR);
                }
-               Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
-               return sortedPosts;
        }
 
        /**