[banshee] [CoverArtSpec] Compile the regex used in EscapePart
- From: Bertrand Lorentz <blorentz src gnome org>
- To: svn-commits-list gnome org
- Subject: [banshee] [CoverArtSpec] Compile the regex used in EscapePart
- Date: Sat, 20 Jun 2009 05:48:37 -0400 (EDT)
commit e34defb97ea01f64d799bfe4d827ab324063de0b
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Sat Jun 20 11:34:11 2009 +0200
[CoverArtSpec] Compile the regex used in EscapePart
Saves some memory allocation and cpu on track change.
src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs b/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
index 0f065a6..5d09b82 100644
--- a/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
+++ b/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
@@ -86,7 +86,8 @@ namespace Banshee.Base
? null
: String.Format ("{0}{1}{2}", sm_artist, asUriPart ? "/" : "-", sm_album);
}
-
+
+ private static Regex filter_regex = new Regex (@"[^A-Za-z0-9]*", RegexOptions.Compiled);
public static string EscapePart (string part)
{
if (String.IsNullOrEmpty (part)) {
@@ -98,8 +99,7 @@ namespace Banshee.Base
part = part.Substring (0, lp_index);
}
- // TODO compile regex
- return Regex.Replace (part, @"[^A-Za-z0-9]*", "").ToLower ();
+ return filter_regex.Replace (part, "").ToLower ();
}
private static string root_path = Path.Combine (XdgBaseDirectorySpec.GetUserDirectory (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]