tomboy r1889 - in trunk: . Tomboy



Author: kkubasik
Date: Sat Feb 23 08:34:24 2008
New Revision: 1889
URL: http://svn.gnome.org/viewvc/tomboy?rev=1889&view=rev

Log:
* Tomboy/Search.cs, Tomboy/NoteManager.cs, Tomboy/Note.cs: Some small
  memory reductions/comments. (mostly inlining some method calls to
  reduce string alloc)

Modified:
   trunk/ChangeLog
   trunk/Tomboy/Note.cs
   trunk/Tomboy/NoteManager.cs
   trunk/Tomboy/Search.cs

Modified: trunk/Tomboy/Note.cs
==============================================================================
--- trunk/Tomboy/Note.cs	(original)
+++ trunk/Tomboy/Note.cs	Sat Feb 23 08:34:24 2008
@@ -395,13 +395,40 @@
 			
 			is_deleting = false;
 		}
-
+		/// <summary>
+		/// Returns a Tomboy URL from the given path.
+		/// </summary>
+		/// <param name="filepath">
+		/// A <see cref="System.String"/>
+		/// </param>
+		/// <returns>
+		/// A <see cref="System.String"/>
+		/// </returns>
 		static string UrlFromPath (string filepath)
 		{
 			return "note://tomboy/" +
 			       Path.GetFileNameWithoutExtension (filepath);
 		}
 
+		public override int GetHashCode ()
+		{
+			return this.Title.GetHashCode();
+		}
+		/// <summary>
+		/// Creates a New Note with the given values.
+		/// </summary>
+		/// <param name="title">
+		/// A <see cref="System.String"/>
+		/// </param>
+		/// <param name="filepath">
+		/// A <see cref="System.String"/>
+		/// </param>
+		/// <param name="manager">
+		/// A <see cref="NoteManager"/>
+		/// </param>
+		/// <returns>
+		/// A <see cref="Note"/>
+		/// </returns>
 		public static Note CreateNewNote (string title,
 		                                  string filepath,
 		                                  NoteManager manager)
@@ -424,6 +451,7 @@
 			return new Note (data, filepath, manager);
 		}
 
+
 		public void Delete ()
 		{
 			is_deleting = true;
@@ -1196,7 +1224,7 @@
 					break;
 				}
 			}
-
+			reader.Close ();
 			xml.Close ();
 
 			if (version != NoteArchiver.CURRENT_VERSION) {
@@ -1345,8 +1373,7 @@
 			List<string> tags = new List<string> ();
 
 			foreach (XmlNode node in tagNodes.SelectNodes ("//tag")) {
-				string tag = node.InnerText;
-				tags.Add (tag);
+				tags.Add (node.InnerText);
 			}
 
 			return tags;

Modified: trunk/Tomboy/NoteManager.cs
==============================================================================
--- trunk/Tomboy/NoteManager.cs	(original)
+++ trunk/Tomboy/NoteManager.cs	Sat Feb 23 08:34:24 2008
@@ -68,7 +68,8 @@
 
 			Tomboy.ExitingEvent += OnExitingEvent;
 		}
-
+		
+		
 		// Create the TrieController. For overriding in test methods.
 		protected virtual TrieController CreateTrieController ()
 		{
@@ -114,12 +115,14 @@
 		{
 			if (NoteRenamed != null)
 				NoteRenamed (note, old_title);
+			this.notes.Sort (new CompareDates ());
 		}
 
 		void OnNoteSave (Note note)
 		{
 			if (NoteSaved != null)
 				NoteSaved (note);
+			this.notes.Sort (new CompareDates ());
 		}
 
 		protected virtual void CreateStartNotes ()
@@ -516,7 +519,7 @@
 			get {
 				// FIXME: Only sort on change by listening to
 				//        Note.Saved or Note.Buffer.Changed
-				notes.Sort (new CompareDates ());
+				//notes.Sort (new CompareDates ());
 				return notes;
 			}
 		}

Modified: trunk/Tomboy/Search.cs
==============================================================================
--- trunk/Tomboy/Search.cs	(original)
+++ trunk/Tomboy/Search.cs	Sat Feb 23 08:34:24 2008
@@ -9,7 +9,7 @@
 	public class Search
 	{
 		private NoteManager manager;
-
+	
 		public Search (NoteManager manager)
 		{
 			this.manager = manager;
@@ -37,11 +37,10 @@
 				bool case_sensitive,
 				Notebooks.Notebook selected_notebook)
 		{
-			string text = query;
-			string [] words = text.Split (' ', '\t', '\n');
+			string [] words = query.Split (' ', '\t', '\n');
 
 			// Used for matching in the raw note XML
-                        string [] encoded_words = XmlEncoder.Encode (text).Split (' ', '\t', '\n');
+            string [] encoded_words = XmlEncoder.Encode (query).Split (' ', '\t', '\n');
 			Dictionary<Note,int> temp_matches = new Dictionary<Note,int>();
 			
 			// Skip over notes that are template notes
@@ -84,7 +83,7 @@
 				note_text = note_text.ToLower ();
 
 			foreach (string word in encoded_words) {
-				if (note_text.IndexOf (word) > -1)
+				if (note_text.Contains (word) )
 					continue;
 				else
 					return false;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]