diff options
author | Marius Ungureanu <teromario@yahoo.com> | 2015-02-03 21:43:15 +0300 |
---|---|---|
committer | Marius Ungureanu <teromario@yahoo.com> | 2015-02-03 21:43:15 +0300 |
commit | 2f12f3d6752144ddbcd5a608bb87781190b04013 (patch) | |
tree | e8032b0e88bddd1cfe4089a4de9eed9e59000708 /main/src | |
parent | ee943316c671ecae5768fb42edff0eb3a527a63a (diff) | |
parent | 52cdd14ddbf9cc58c9e58b6ff6003bba00eb5891 (diff) |
Merge pull request #691 from mono/perfImprovements
Performance Improvements
Diffstat (limited to 'main/src')
12 files changed, 72 insertions, 44 deletions
diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/GtkDesignInfo.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/GtkDesignInfo.cs index fe52c08623..e19b126148 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/GtkDesignInfo.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/GtkDesignInfo.cs @@ -194,11 +194,10 @@ namespace MonoDevelop.GtkCore public static bool HasDesignedObjects (Project project) { - if (project == null) + if (project == null || !SupportsDesigner (project)) return false; - string stetic_file = Path.Combine (Path.Combine (project.BaseDirectory, "gtk-gui"), "gui.stetic"); - return SupportsDesigner (project) && File.Exists (stetic_file); + return File.Exists (Path.Combine (project.BaseDirectory, "gtk-gui", "gui.stetic")); } public static bool SupportsDesigner (Project project) @@ -214,8 +213,13 @@ namespace MonoDevelop.GtkCore { if (project == null || project.LanguageBinding == null || project.LanguageBinding.GetCodeDomProvider () == null) return false; + if (project.ExtendedProperties.Contains ("GtkRefactoringSupported")) + return (bool)project.ExtendedProperties ["GtkRefactoringSupported"]; + var testFileName = project.LanguageBinding.GetFileName ("test"); - return CodeGenerator.HasGenerator (DesktopService.GetMimeTypeForUri (testFileName)); + bool hasSupport = CodeGenerator.HasGenerator (DesktopService.GetMimeTypeForUri (testFileName)); + project.ExtendedProperties ["GtkRefactoringSupported"] = hasSupport; + return hasSupport; } static bool IsGtkReference (ProjectReference pref) @@ -223,20 +227,22 @@ namespace MonoDevelop.GtkCore if (pref.ReferenceType != ReferenceType.Package) return false; - int idx = pref.StoredReference.IndexOf (","); - if (idx == -1) - return false; - - string name = pref.StoredReference.Substring (0, idx).Trim (); - return name == "gtk-sharp"; + return pref.StoredReference.StartsWith ("gtk-sharp,"); } static bool HasGtkReference (DotNetProject project) { + if (project.ExtendedProperties.Contains ("GtkReferenceExists")) + return (bool)project.ExtendedProperties ["GtkReferenceExists"]; + + bool found = false; foreach (ProjectReference pref in project.References) - if (IsGtkReference (pref)) - return true; - return false; + if (IsGtkReference (pref)) { + found = true; + break; + } + project.ExtendedProperties ["GtkReferenceExists"] = found; + return found; } public void ForceCodeGenerationOnBuild () diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ReferenceManager.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ReferenceManager.cs index 3c97bc2302..41b235eb7b 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ReferenceManager.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ReferenceManager.cs @@ -212,6 +212,7 @@ namespace MonoDevelop.GtkCore { if (updating || !IsGtkReference (args.ProjectReference)) return; + args.Project.ExtendedProperties ["GtkReferenceExists"] = true; string sr = args.ProjectReference.StoredReference; string version = sr.Substring (sr.IndexOf (",") + 1).Trim (); ReferenceManager rm = new ReferenceManager (args.Project as DotNetProject); @@ -225,9 +226,10 @@ namespace MonoDevelop.GtkCore { DotNetProject dnp = args.Project as DotNetProject; - if (MessageService.Confirm (GettextCatalog.GetString ("The Gtk# User Interface designer will be disabled by removing the gtk-sharp reference."), new AlertButton (GettextCatalog.GetString ("Disable Designer")))) + if (MessageService.Confirm (GettextCatalog.GetString ("The Gtk# User Interface designer will be disabled by removing the gtk-sharp reference."), new AlertButton (GettextCatalog.GetString ("Disable Designer")))) { + dnp.ExtendedProperties ["GtkReferenceExists"] = false; GtkDesignInfo.DisableProject (dnp); - else + } else dnp.References.Add (new ProjectReference (ReferenceType.Package, args.ProjectReference.StoredReference)); } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs index 70b53bfe00..c96c5161bb 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs @@ -122,7 +122,8 @@ namespace MonoDevelop.SourceEditor } } - static AutoResetEvent resetEvent = new AutoResetEvent (false); + static readonly AutoResetEvent resetEvent = new AutoResetEvent (false); + static readonly AutoResetEvent saveEvent = new AutoResetEvent (false); static bool autoSaveThreadRunning = false; static Thread autoSaveThread; static Queue<FileContent> queue = new Queue<FileContent> (); @@ -148,18 +149,23 @@ namespace MonoDevelop.SourceEditor // Don't create an auto save for unsaved files. if (string.IsNullOrEmpty (content.FileName)) continue; + string text = null; + bool set = false; Application.Invoke (delegate { - string text; try { text = content.Content.Text; + set = true; } catch (Exception e) { LoggingService.LogError ("Exception in auto save thread.", e); return; + } finally { + saveEvent.Set(); } - CreateAutoSave (content.FileName, text); } ); - + saveEvent.WaitOne (); + if (set) + CreateAutoSave (content.FileName, text); } } } diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SemanticRule.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SemanticRule.cs index 18da23014d..0c8964a43d 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SemanticRule.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SemanticRule.cs @@ -60,7 +60,7 @@ namespace Mono.TextEditor try { string text = doc.GetTextAt (startOffset, System.Math.Min (endOffset, doc.TextLength) - startOffset); int startColumn = startOffset - line.Offset; - var markers = new List <UrlMarker> (line.Markers.Where (m => m is UrlMarker).Cast<UrlMarker> ()); + var markers = new List <UrlMarker> (line.Markers.OfType<UrlMarker> ()); markers.ForEach (m => doc.RemoveMarker (m, false)); foreach (System.Text.RegularExpressions.Match m in UrlRegex.Matches (text)) { doc.AddMarker (line, new UrlMarker (doc, line, m.Value, UrlType.Url, syntax, startColumn + m.Index, startColumn + m.Index + m.Length), false); diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs index b180208ace..0d9ecc76fb 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxMode.cs @@ -333,8 +333,9 @@ namespace Mono.TextEditor.Highlighting protected virtual bool ScanSpan (ref int i) { int textOffset = i - StartOffset; - for (int j = 0; j < CurRule.Spans.Length; j++) { - Span span = CurRule.Spans [j]; + Span[] spans = CurRule.Spans; + for (int j = 0; j < spans.Length; j++) { + Span span = spans [j]; if ((span.BeginFlags & SpanBeginFlags.StartsLine) == SpanBeginFlags.StartsLine) { if (textOffset != 0) { diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs index b15350f37b..4bb605a4c1 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs @@ -149,11 +149,8 @@ namespace MonoDevelop.Core }
public FilePath Combine (params string[] paths)
- {
- string path = fileName;
- foreach (string p in paths)
- path = Path.Combine (path, p);
- return new FilePath (path);
+ { + return new FilePath (Path.Combine (fileName, Path.Combine (paths)));
} public void Delete () diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs index eb66407e1d..8d286172bf 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs @@ -120,7 +120,7 @@ namespace MonoDevelop.Projects einfo.ItemTypeCondition.ObjType = target.GetType (); einfo.ProjectLanguageCondition.TargetProject = target; } - ProjectServiceExtension[] extensions = einfo.ExtensionContext.GetExtensionObjects ("/MonoDevelop/ProjectModel/ProjectServiceExtensions", typeof(ProjectServiceExtension)).Cast<ProjectServiceExtension> ().ToArray (); + ProjectServiceExtension[] extensions = einfo.ExtensionContext.GetExtensionObjects<ProjectServiceExtension> ("/MonoDevelop/ProjectModel/ProjectServiceExtensions"); chain = CreateExtensionChain (extensions); // After creating the chain there is no need to keep the reference to the target @@ -132,7 +132,7 @@ namespace MonoDevelop.Projects ExtensionContext ctx = AddinManager.CreateExtensionContext (); ctx.RegisterCondition ("ItemType", new ItemTypeCondition (typeof(UnknownItem))); ctx.RegisterCondition ("ProjectLanguage", new ProjectLanguageCondition (UnknownItem.Instance)); - ProjectServiceExtension[] extensions = ctx.GetExtensionObjects ("/MonoDevelop/ProjectModel/ProjectServiceExtensions", typeof(ProjectServiceExtension)).Cast<ProjectServiceExtension> ().ToArray (); + ProjectServiceExtension[] extensions = ctx.GetExtensionObjects<ProjectServiceExtension> ("/MonoDevelop/ProjectModel/ProjectServiceExtensions"); defaultExtensionChain = CreateExtensionChain (extensions); } chain = defaultExtensionChain; diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItemCollection.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItemCollection.cs index d10df9649d..e7604fbe92 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItemCollection.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItemCollection.cs @@ -27,6 +27,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections; namespace MonoDevelop.Projects { @@ -37,6 +38,10 @@ namespace MonoDevelop.Projects public WorkspaceItemCollection () { } + + public WorkspaceItemCollection (IList<WorkspaceItem> list) : base(list) + { + } internal WorkspaceItemCollection (Workspace parent) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenuItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenuItem.cs index df4cdae1de..4f9a63b7d2 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenuItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenuItem.cs @@ -98,8 +98,9 @@ namespace MonoDevelop.Components.Commands base.OnParentSet (parent); if (Parent == null) return; - - ((ICommandUserItem)this).Update (new CommandTargetRoute ()); + + if (Parent.Visible) + ((ICommandUserItem)this).Update (new CommandTargetRoute ()); if (!isArrayItem) { // Make sure the accelerators always work for this item diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ShowAllFilesBuilderExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ShowAllFilesBuilderExtension.cs index 0e196a3c82..f7dcdfd1d1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ShowAllFilesBuilderExtension.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ShowAllFilesBuilderExtension.cs @@ -110,9 +110,12 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad public override void BuildNode (ITreeBuilder builder, object dataObject, NodeInfo nodeInfo) { + if (!builder.Options ["ShowAllFiles"]) + return; + string thisPath = GetFolderPath (dataObject); - if ((dataObject is ProjectFolder) && builder.Options ["ShowAllFiles"] && Directory.Exists (thisPath)) + if ((dataObject is ProjectFolder) && Directory.Exists (thisPath)) { ProjectFolder pf = (ProjectFolder) dataObject; if (pf.Project == null || !ProjectFolderCommandHandler.PathExistsInProject (pf.Project, thisPath)) { @@ -134,8 +137,11 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad public override void BuildChildNodes (ITreeBuilder builder, object dataObject) { + if (!builder.Options ["ShowAllFiles"]) + return; + string path = GetFolderPath (dataObject); - if (builder.Options ["ShowAllFiles"] && Directory.Exists (path)) + if (Directory.Exists (path)) { Project project = (Project) builder.GetParentDataItem (typeof(Project), true); SolutionFolderFileCollection folderFiles = null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs index 7f3d47920f..2dadadf773 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs @@ -1146,13 +1146,13 @@ namespace MonoDevelop.Ide.Gui List<FileData> fileStatus; object fileStatusLock = new object (); - + // http://msdn.microsoft.com/en-us/library/system.io.file.getlastwritetimeutc(v=vs.110).aspx + static DateTime NonExistentFile = new DateTime(1601, 1, 1); internal void SaveFileStatus () { - fileStatus = new List<FileData> (); - // DateTime t = DateTime.Now; List<FilePath> files = new List<FilePath> (GetKnownFiles ()); + fileStatus = new List<FileData> (files.Count); // Console.WriteLine ("SaveFileStatus(0) " + (DateTime.Now - t).TotalMilliseconds + "ms " + files.Count); ThreadPool.QueueUserWorkItem (delegate { @@ -1160,8 +1160,8 @@ namespace MonoDevelop.Ide.Gui lock (fileStatusLock) { foreach (FilePath file in files) { try { - FileInfo fi = new FileInfo (file); - FileData fd = new FileData (file, fi.Exists ? fi.LastWriteTimeUtc : DateTime.MinValue); + DateTime ft = File.GetLastWriteTimeUtc (file); + FileData fd = new FileData (file, ft != NonExistentFile ? ft : DateTime.MinValue); fileStatus.Add (fd); } catch { // Ignore @@ -1182,12 +1182,12 @@ namespace MonoDevelop.Ide.Gui // DateTime t = DateTime.Now; if (fileStatus == null) return; - List<FilePath> modified = new List<FilePath> (); + List<FilePath> modified = new List<FilePath> (fileStatus.Count); foreach (FileData fd in fileStatus) { try { - FileInfo fi = new FileInfo (fd.File); - if (fi.Exists) { - if (fi.LastWriteTimeUtc != fd.TimeUtc) + DateTime ft = File.GetLastWriteTimeUtc (fd.File); + if (ft != NonExistentFile) { + if (ft != fd.TimeUtc) modified.Add (fd.File); } else if (fd.TimeUtc != DateTime.MinValue) { FileService.NotifyFileRemoved (fd.File); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs index 087df0608e..d000e6d275 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs @@ -102,7 +102,7 @@ namespace MonoDevelop.Ide public WorkspaceItemCollection Items { get { if (items == null) - items = new RootWorkspaceItemCollection (this); + items = new RootWorkspaceItemCollection (this, 256); return items; } } @@ -1411,7 +1411,11 @@ namespace MonoDevelop.Ide { RootWorkspace parent; - public RootWorkspaceItemCollection (RootWorkspace parent) + public RootWorkspaceItemCollection (RootWorkspace parent) : this(parent, 0) + { + } + + public RootWorkspaceItemCollection (RootWorkspace parent, int capacity) : base(new List<WorkspaceItem> (capacity)) { this.parent = parent; } |