[smuxi/experiments/certfp: 42/55] Engine: cache built-in smart links (regexes)
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi/experiments/certfp: 42/55] Engine: cache built-in smart links (regexes)
- Date: Sun, 12 Jan 2014 07:29:36 +0000 (UTC)
commit b9b5eaab869c9648a4d9c976cc8a36856ae02f92
Author: Mirco Bauer <meebey meebey net>
Date: Sat Jan 11 04:15:44 2014 +0100
Engine: cache built-in smart links (regexes)
src/Engine/Config/MessageBuilderSettings.cs | 70 +++++++++++++++-----------
1 files changed, 40 insertions(+), 30 deletions(-)
---
diff --git a/src/Engine/Config/MessageBuilderSettings.cs b/src/Engine/Config/MessageBuilderSettings.cs
index 8e8056d..e59513c 100644
--- a/src/Engine/Config/MessageBuilderSettings.cs
+++ b/src/Engine/Config/MessageBuilderSettings.cs
@@ -44,15 +44,25 @@ namespace Smuxi.Engine
}
}
+ static List<SmartLink> BuiltinSmartLinks { get; set; }
public List<SmartLink> SmartLinks { get; private set; }
+ static MessageBuilderSettings()
+ {
+ BuiltinSmartLinks = new List<SmartLink>();
+ InitBuiltinSmartLinks();
+ }
+
public MessageBuilderSettings()
{
- SmartLinks = new List<SmartLink>();
- InitDefaultLinks();
+ // No need to lock BuiltinSmartLinks as List<T> is thread-safe for
+ // multiple readers as long as there is no writer at the same time.
+ // BuiltinSmartLinks is only written once before the first instance
+ // of MessageBuilderSettings is created via the static initializer.
+ SmartLinks = new List<SmartLink>(BuiltinSmartLinks);
}
- void InitDefaultLinks()
+ static void InitBuiltinSmartLinks()
{
string path_last_chars = @"a-zA-Z0-9#/%&=\-_+;~";
string path_chars = path_last_chars + @")(?.,";
@@ -73,18 +83,18 @@ namespace Smuxi.Engine
var regex = new Regex(
@"(<[1-9][0-9]* attachments?>)
(http://www\.facebook\.com/messages/\?action=read&tid=[0-9a-f]+)"
);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "{2}",
TextFormat = "{1}",
});
// protocol://domain
regex = new Regex(@"[a-z][a-z0-9\-]*://" + address, RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex));
+ BuiltinSmartLinks.Add(new SmartLink(regex));
// email
regex = new Regex(@"(?:mailto:)?(" + user_domain + ")", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "mailto:{1}"
});
@@ -94,19 +104,19 @@ namespace Smuxi.Engine
string heuristic_domain = @"(?:(?:" + subdomain + ")+(?:" + common_tld + ")|localhost)";
string heuristic_address = heuristic_domain + "(?:" + path + ")?";
regex = new Regex(heuristic_address, RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://{0}"
});
// Smuxi bugtracker
regex = new Regex(@"smuxi#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://www.smuxi.org/issues/show/{1}"
});
// RFCs
regex = new Regex(@"RFC[ -]?([0-9]+)");
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://www.ietf.org/rfc/rfc{1}.txt"
});
@@ -115,127 +125,127 @@ namespace Smuxi.Engine
// boost bugtracker
regex = new Regex(@"boost#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "https://svn.boost.org/trac/boost/ticket/{1}"
});
// Claws bugtracker
regex = new Regex(@"claws#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://www.thewildbeast.co.uk/claws-mail/bugzilla/show_bug.cgi?id={1}"
});
// CVE list
regex = new Regex(@"CVE-[0-9]{4}-[0-9]{4,}", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://cve.mitre.org/cgi-bin/cvename.cgi?name={0}"
});
// CPAN bugtracker
regex = new Regex(@"RT#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://rt.cpan.org/Public/Bug/Display.html?id={1}"
});
// Debian bugtracker
regex = new Regex(@"deb#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugs.debian.org/{1}"
});
// Debian Security Advisories (DSA)
regex = new Regex(@"DSA-([0-9]{4})(-[0-9]{1,2})?", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://www.debian.org/security/dsa-{1}"
});
// openSUSE feature tracker
regex = new Regex(@"fate#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://features.opensuse.org/{1}"
});
// freedesktop bugtracker
regex = new Regex(@"fdo#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugs.freedesktop.org/{1}"
});
// GNU bugtracker
regex = new Regex(@"gnu#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://debbugs.gnu.org/{1}"
});
// GCC bugtracker
regex = new Regex(@"gcc#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://gcc.gnu.org/bugzilla/show_bug.cgi?id={1}"
});
// GNOME bugtracker
regex = new Regex(@"bgo#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugzilla.gnome.org/{1}"
});
// KDE bugtracker
regex = new Regex(@"kde#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugs.kde.org/{1}"
});
// kernel bugtracker
regex = new Regex(@"bko#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugzilla.kernel.org/show_bug.cgi?id={1}"
});
// launchpad bugtracker
regex = new Regex(@"LP#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://launchpad.net/bugs/{1}"
});
// Mozilla bugtracker
regex = new Regex(@"bmo#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugzilla.mozilla.org/{1}"
});
// Novell bugtracker
regex = new Regex(@"bnc#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugzilla.novell.com/{1}"
});
// Redhat bugtracker
regex = new Regex(@"rh#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugzilla.redhat.com/{1}"
});
// Samba bugtracker
regex = new Regex(@"bso#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugzilla.samba.org/show_bug.cgi?id={1}"
});
// sourceforge bugtracker
regex = new Regex(@"sf#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://sf.net/support/tracker.php?aid={1}"
});
// Xfce bugtracker
regex = new Regex(@"bxo#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugzilla.xfce.org/show_bug.cgi?id={1}"
});
// Xamarin bugtracker
regex = new Regex(@"bxc#([0-9]+)", RegexOptions.IgnoreCase);
- SmartLinks.Add(new SmartLink(regex) {
+ BuiltinSmartLinks.Add(new SmartLink(regex) {
LinkFormat = "http://bugzilla.xamarin.com/show_bug.cgi?id={1}"
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]