From b1b2e4a0419ef5cb5f45b7ad5ccb0b3b97507b1d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 13 Feb 2020 04:50:04 +0300 Subject: [PATCH] Simplify parent comment assignment --- osu.Game/Overlays/Comments/CommentsPage.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Comments/CommentsPage.cs b/osu.Game/Overlays/Comments/CommentsPage.cs index 5d64313e4f..43a223be8b 100644 --- a/osu.Game/Overlays/Comments/CommentsPage.cs +++ b/osu.Game/Overlays/Comments/CommentsPage.cs @@ -63,9 +63,10 @@ namespace osu.Game.Overlays.Comments createBaseTree(commentBundle.Comments); } + private readonly Dictionary nodeDictionary = new Dictionary(); + private void createBaseTree(List comments) { - var nodeDictionary = new Dictionary(); var topLevelNodes = new List(); var orphanedNodes = new List(); @@ -82,7 +83,6 @@ namespace osu.Game.Overlays.Comments { if (orphan.ParentId == comment.Id) { - orphan.ParentComment = comment; comment.ChildComments.Add(orphan); orphanedNodes.Remove(orphan); } @@ -93,10 +93,7 @@ namespace osu.Game.Overlays.Comments continue; if (nodeDictionary.ContainsKey(comment.ParentId.Value)) - { - comment.ParentComment = nodeDictionary[comment.ParentId.Value]; nodeDictionary[comment.ParentId.Value].ChildComments.Add(comment); - } else orphanedNodes.Add(comment); } @@ -107,6 +104,9 @@ namespace osu.Game.Overlays.Comments private DrawableComment createCommentWithReplies(Comment comment) { + if (comment.ParentId.HasValue) + comment.ParentComment = nodeDictionary[comment.ParentId.Value]; + var drawableComment = createDrawableComment(comment); var replies = comment.ChildComments;