Browse Source

Performance improvements for solution loading:

- Fixed bug in SVN OverlayIconManager that could cause two worker threads to be started.
- Fixed performance bug in SvnClientWrapper.SingleStatus.
- DefaultProjectContent.AddClassToNamespaceListInternal: do not try to update existing class in namespace's classList if we're adding a new class.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4220 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
9237bea45a
  1. 10
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs
  2. 22
      src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs
  3. 12
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs
  4. 4
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/XmlDoc.cs

10
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs

@ -87,6 +87,7 @@ namespace ICSharpCode.Svn @@ -87,6 +87,7 @@ namespace ICSharpCode.Svn
}
static Queue<AbstractProjectBrowserTreeNode> queue = new Queue<AbstractProjectBrowserTreeNode>();
static bool threadRunning;
public static void Enqueue(AbstractProjectBrowserTreeNode node)
{
@ -94,7 +95,8 @@ namespace ICSharpCode.Svn @@ -94,7 +95,8 @@ namespace ICSharpCode.Svn
return;
lock (queue) {
queue.Enqueue(node);
if (queue.Count == 1) {
if (!threadRunning) {
threadRunning = true;
ThreadPool.QueueUserWorkItem(Run);
}
}
@ -105,8 +107,6 @@ namespace ICSharpCode.Svn @@ -105,8 +107,6 @@ namespace ICSharpCode.Svn
if (subversionDisabled)
return;
lock (queue) {
bool wasEmpty = queue.Count == 0;
queue.Enqueue(node);
// use breadth-first search
Queue<AbstractProjectBrowserTreeNode> q = new Queue<AbstractProjectBrowserTreeNode>();
@ -122,7 +122,8 @@ namespace ICSharpCode.Svn @@ -122,7 +122,8 @@ namespace ICSharpCode.Svn
}
}
if (wasEmpty) {
if (!threadRunning) {
threadRunning = true;
ThreadPool.QueueUserWorkItem(Run);
}
}
@ -150,6 +151,7 @@ namespace ICSharpCode.Svn @@ -150,6 +151,7 @@ namespace ICSharpCode.Svn
AbstractProjectBrowserTreeNode node;
lock (queue) {
if (queue.Count == 0) {
threadRunning = false;
ClearStatusCache();
LoggingService.Debug("SVN: OverlayIconManager Thread finished");
return;

22
src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs

@ -113,7 +113,6 @@ namespace ICSharpCode.Svn @@ -113,7 +113,6 @@ namespace ICSharpCode.Svn
#endregion
SvnClient client;
Dictionary<string, Status> statusCache = new Dictionary<string, Status>(StringComparer.OrdinalIgnoreCase);
public SvnClientWrapper()
{
@ -129,7 +128,6 @@ namespace ICSharpCode.Svn @@ -129,7 +128,6 @@ namespace ICSharpCode.Svn
if (client != null)
client.Dispose();
client = null;
statusCache = null;
}
#region Authorization
@ -203,7 +201,6 @@ namespace ICSharpCode.Svn @@ -203,7 +201,6 @@ namespace ICSharpCode.Svn
public void ClearStatusCache()
{
CheckNotDisposed();
statusCache.Clear();
}
public Status SingleStatus(string filename)
@ -212,29 +209,22 @@ namespace ICSharpCode.Svn @@ -212,29 +209,22 @@ namespace ICSharpCode.Svn
BeforeOperation("stat");
try {
filename = FileUtility.NormalizePath(filename);
Status result;
if (statusCache.TryGetValue(filename, out result)) {
Debug("SVN: SingleStatus retrieved from cache " + result.TextStatus);
return result;
}
SvnStatusArgs args = new SvnStatusArgs {
Revision = SvnRevision.Working,
RetrieveAllEntries = true,
RetrieveIgnoredEntries = true
RetrieveIgnoredEntries = true,
Depth = SvnDepth.Empty
};
Status result = null;
client.Status(
filename, args,
delegate (object sender, SvnStatusEventArgs e) {
string dir = e.FullPath;
Debug("SVN: SingleStatus.callback(" + dir + "," + e.LocalContentStatus + ")");
Status s = new Status {
Debug("SVN: SingleStatus.callback(" + e.FullPath + "," + e.LocalContentStatus + ")");
System.Diagnostics.Debug.Assert(filename.Equals(e.FullPath, StringComparison.OrdinalIgnoreCase));
result = new Status {
Copied = e.LocalCopied,
TextStatus = ToStatusKind(e.LocalContentStatus)
};
statusCache[dir] = s;
if (StringComparer.OrdinalIgnoreCase.Equals(filename, dir)) {
result = s;
}
}
);
if (result != null) {

12
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs

@ -370,6 +370,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -370,6 +370,7 @@ namespace ICSharpCode.SharpDevelop.Dom
void AddClassToNamespaceListInternal2(IClass addClass)
{
bool isReplacingExistingClass = false;
string fullyQualifiedName = addClass.FullyQualifiedName;
IClass oldDictionaryClass;
if (GetClasses(language).TryGetValue(fullyQualifiedName, out oldDictionaryClass)) {
@ -382,6 +383,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -382,6 +383,7 @@ namespace ICSharpCode.SharpDevelop.Dom
gcc.Set(addClass);
gcc.Set(oldDictionaryClass);
addClass = gcc;
isReplacingExistingClass = true;
}
}
@ -394,10 +396,12 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -394,10 +396,12 @@ namespace ICSharpCode.SharpDevelop.Dom
}
CreateNamespace(nSpace);
List<IClass> classList = GetNamespaces(this.language)[nSpace].Classes;
for (int i = 0; i < classList.Count; i++) {
if (classList[i].FullyQualifiedName == fullyQualifiedName) {
classList[i] = addClass;
return;
if (isReplacingExistingClass) {
for (int i = 0; i < classList.Count; i++) {
if (classList[i].FullyQualifiedName == fullyQualifiedName) {
classList[i] = addClass;
return;
}
}
}
classList.Add(addClass);

4
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/XmlDoc.cs

@ -146,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -146,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.Dom
bool LoadFromBinary(string fileName, DateTime fileDate)
{
keyCacheQueue = new Queue<string>(cacheLength);
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete);
int len = (int)fs.Length;
loader = new BinaryReader(fs);
try {
@ -164,7 +164,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -164,7 +164,7 @@ namespace ICSharpCode.SharpDevelop.Dom
}
int count = loader.ReadInt32();
int indexStartPosition = loader.ReadInt32(); // go to start of index
if (indexStartPosition >= len) {
if (indexStartPosition <= 0 || indexStartPosition >= len) {
LoggingService.Error("XmlDoc: Cannot find index, cache invalid!");
return false;
}

Loading…
Cancel
Save