Changeset 20715 for lang/csharp

Show
Ignore:
Timestamp:
10/04/08 23:01:35 (2 months ago)
Author:
poolmmjp
Message:

テンプレートを読み込んでくる所をキャッシュするようにして、高速化を試みた。

Location:
lang/csharp/MMMMB/MMMMB
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/csharp/MMMMB/MMMMB/MiniBlogView.cs

    r20712 r20715  
    180180            Filter deny = Filter.Parse(filterCheck.Checked ? InvokeComboText(denyInput) : ""); 
    181181            Filter allow = Filter.Parse(filterCheck.Checked ? InvokeComboText(allowInput) : ""); 
     182            Template.ClearCache(); 
    182183            StringBuilder sb = new StringBuilder(); 
    183184            int count = 0; 
  • lang/csharp/MMMMB/MMMMB/Template.cs

    r10019 r20715  
    99    class Template 
    1010    { 
    11         private string tmpl; 
     11        private static Dictionary<string, string> tmplates = new Dictionary<string,string>(); 
     12 
     13        public static void ClearCache() 
     14        { 
     15            tmplates.Clear(); 
     16        } 
     17 
     18        private string filename; 
    1219        private Dictionary<string, string> values = new Dictionary<string, string>(); 
    1320 
    1421        public Template(string filename) 
    1522        { 
    16             this.tmpl = File.ReadAllText(filename + ".template"); 
     23            this.filename = filename + ".template"; 
     24            if (!tmplates.ContainsKey(this.filename)) 
     25            { 
     26                tmplates.Add(this.filename, File.ReadAllText(this.filename)); 
     27            } 
    1728        } 
    1829 
     
    2435        public override string ToString() 
    2536        { 
    26              return Regex.Replace(this.tmpl, @"\[\[(.+?)\]\]", new MatchEvaluator(delegate(Match m){ 
     37            return Regex.Replace(tmplates[this.filename], @"\[\[(.+?)\]\]", new MatchEvaluator(delegate(Match m) 
     38            { 
    2739                 string key = m.Groups[1].Value; 
    2840                 if(!this.values.ContainsKey(key)) return m.Groups[0].Value;