Changeset 3061


Ignore:
Timestamp:
11/27/05 12:23:22 (7 years ago)
Author:
moschny
Message:
  • Reuse the TocFormatter object for formatting all toc entries - this might yield a performance enhancement (hard to measure).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trac/trunk/wiki-macros/TracNav.py

    r3060 r3061  
    100100    last wiki link. 
    101101    """ 
    102  
    103     def format_toc(self, wikitext, out): 
     102    def format_toc(self, wikitext): 
     103        self.link = None 
     104        out = StringIO() 
    104105        OneLinerFormatter.format(self, wikitext, out) 
    105         return self.link 
     106        return out.getvalue(), self.link 
    106107 
    107108    def __init__(self, env): 
     
    118119    # FIXME: CamelCase links are special and not handled by the Formatter... 
    119120 
    120 def format_toc_entry(wikitext, env): 
    121     out = StringIO() 
    122     link = TocFormatter(env).format_toc(wikitext, out) 
    123     return out.getvalue(), link 
    124  
    125121 
    126122def get_toc_entry(toc_text, env): 
     
    128124    Parse and format the entries in toc_text. 
    129125    """ 
     126    formatter = TocFormatter(env) 
    130127    for match in LISTRULE.finditer(toc_text): 
    131128        indent = len(match.group('indent')) 
    132         label, link = format_toc_entry(match.group('rest'), env) 
     129        label, link = formatter.format_toc(match.group('rest')) 
    133130        yield indent, link, label 
    134131 
     
    176173    """ 
    177174    gen = get_toc_entry_and_indent(get_toc_entry(toc_text, env)) 
    178     toclist, _ = _parse_toc(gen, gen.next()) 
    179     return toclist 
     175    toc, _ = _parse_toc(gen, gen.next()) 
     176    return toc 
    180177    
    181178 
Note: See TracChangeset for help on using the changeset viewer.