Skip to content

Commit aab2e8e

Browse files
Use Concurrent Dictionary (#8686)
1 parent 9c79886 commit aab2e8e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/dotnet/APIView/APIViewWeb/Helpers/CodeFileHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,12 @@ private static void InsertCodePanelRowData(CodePanelData codePanelData, CodePane
738738
commentsForRow.AssociatedRowPositionInGroup = rowData.RowPositionInGroup;
739739
if (codePanelData.NodeMetaDataObj.ContainsKey(nodeIdHashed))
740740
{
741-
codePanelData.NodeMetaDataObj[nodeIdHashed].CommentThreadObj.Add(codePanelData.NodeMetaDataObj[nodeIdHashed].CodeLinesObj.Count() - 1, commentsForRow); //Map comment to the index of associated codeLine
741+
codePanelData.NodeMetaDataObj[nodeIdHashed].CommentThreadObj.TryAdd(codePanelData.NodeMetaDataObj[nodeIdHashed].CodeLinesObj.Count() - 1, commentsForRow); //Map comment to the index of associated codeLine
742742
}
743743
else
744744
{
745745
codePanelData.NodeMetaDataObj.TryAdd(nodeIdHashed, new CodePanelNodeMetaData());
746-
codePanelData.NodeMetaDataObj[nodeIdHashed].CommentThreadObj.Add(codePanelData.NodeMetaDataObj[nodeIdHashed].CodeLinesObj.Count() - 1, commentsForRow); //Map comment to the index of associated codeLine
746+
codePanelData.NodeMetaDataObj[nodeIdHashed].CommentThreadObj.TryAdd(codePanelData.NodeMetaDataObj[nodeIdHashed].CodeLinesObj.Count() - 1, commentsForRow); //Map comment to the index of associated codeLine
747747
}
748748
}
749749
}

src/dotnet/APIView/APIViewWeb/LeanModels/ReviewRevisionPageModels.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ public class CodePanelNodeMetaData
111111
public List<CodePanelRowData> CodeLinesObj { get; set; } = new List<CodePanelRowData>();
112112
public List<CodePanelRowData> CodeLines => CodeLinesObj.Count > 0 ? CodeLinesObj : null;
113113
[JsonIgnore]
114-
public Dictionary<int, CodePanelRowData> CommentThreadObj { get; set; } = new Dictionary<int, CodePanelRowData>(); //Dictionary key map to the index of the code line within this node which the comment thread is mapped to
115-
public Dictionary<int, CodePanelRowData> CommentThread => CommentThreadObj.Count > 0 ? CommentThreadObj : null;
114+
public ConcurrentDictionary<int, CodePanelRowData> CommentThreadObj { get; set; } = new ConcurrentDictionary<int, CodePanelRowData>(); //Dictionary key map to the index of the code line within this node which the comment thread is mapped to
115+
public ConcurrentDictionary<int, CodePanelRowData> CommentThread => CommentThreadObj.Count > 0 ? CommentThreadObj : null;
116116
public NavigationTreeNode NavigationTreeNode { get; set; }
117117
public string ParentNodeIdHashed { get; set; }
118118
[JsonIgnore]

0 commit comments

Comments
 (0)