From: David ‘Bombe’ Roden Date: Fri, 5 Nov 2010 22:42:04 +0000 (+0100) Subject: Use better synchronization and the pre-defined post comparator. X-Git-Tag: 0.2-RC1~6 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6187b535deb8c1b727e41f2c204b0f9311a8e31b;p=Sone.git Use better synchronization and the pre-defined post comparator. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 3ff0d3b..fd69832 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -362,15 +362,11 @@ public class Sone { * @return All posts of this Sone */ public List getPosts() { - List sortedPosts = new ArrayList(posts); - Collections.sort(sortedPosts, new Comparator() { - - @Override - public int compare(Post leftPost, Post rightPost) { - return (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, rightPost.getTime() - leftPost.getTime())); - } - - }); + List sortedPosts; + synchronized (this) { + sortedPosts = new ArrayList(posts); + } + Collections.sort(sortedPosts, Post.TIME_COMPARATOR); return sortedPosts; }