Skip to content

Commit

Permalink
- Fixed a performance issue in Navi Bar introduced in previous commits
Browse files Browse the repository at this point in the history
  • Loading branch information
wmjordan committed Dec 22, 2018
1 parent c660485 commit fdebbfb
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Codist/NaviBar/CSharpBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,36 +133,41 @@ async void Update(object sender, EventArgs e) {
async Task Update(CancellationToken token) {
var nodes = await UpdateModelAsync(token);
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(token);
var c = Math.Min(Items.Count - 1, nodes.Count);
int i;
for (i = 0; i < c; i++) {
var n = nodes[i];
var c = Math.Min(Items.Count, nodes.Count);
int i, i2;
for (i = 1, i2 = 0; i < c && i2 < c; i2++) {
var n = nodes[i2];
if (token.IsCancellationRequested) {
return;
}
if ((Items[i + 1] as NaviItem).Node == n) {
var n2 = (Items[i] as NaviItem).Node;
if (n2 == n) {
// keep the NaviItem if node is not updated
++i;
continue;
}
if (n.IsKind(SyntaxKind.NamespaceDeclaration)) {
continue;
}
break;
}
if ((i == 0 || nodes[i - 1].IsTypeOrNamespaceDeclaration()) && _RootItem.FilterText.Length == 0) {
if ((i == 1 || i2 < nodes.Count && nodes[i2].IsTypeOrNamespaceDeclaration()) && _RootItem.FilterText.Length == 0) {
// clear type and namespace menu items if a type is changed
_RootItem.ClearItems();
}
c = Items.Count;
while (--c > i) {
Items.RemoveAt(c);
while (c > i) {
Items.RemoveAt(--c);
}
c = nodes.Count;
while (i < c) {
while (i2 < c) {
if (token.IsCancellationRequested) {
return;
}
var node = nodes[i];
var node = nodes[i2];
if (node.IsKind(SyntaxKind.NamespaceDeclaration)) {
_RootItem.SetText(node.GetDeclarationSignature());
++i;
++i2;
continue;
}
bool highlight = node.IsMemberDeclaration();
Expand All @@ -171,7 +176,7 @@ async Task Update(CancellationToken token) {
newItem.IsChecked = true;
}
Items.Add(newItem);
++i;
++i2;
}
}
}
Expand Down

0 comments on commit fdebbfb

Please sign in to comment.