Simplify sorting of posts.
[Sone.git] / 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;
        }
 
        /**