#9056 closed enhancement (fixed)
Refactor trac.mimeview.pygments.GenshiHtmlFormatter for clarity.
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | normal | Milestone: | 0.12 |
Component: | version control/browser | Version: | 0.12dev |
Severity: | minor | Keywords: | genshi mimeview highlighting |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
The generate()
method currently does two things at once: it's chunking together tokens with the same class, and it's also outputting HTML tags. This patch separates them into two separate methods to improved clarity. Since both methods are just iterating over a generator, there's no additional memory overhead.
This does change code for the sake of just readability, but hopefully someone hacking on GenshiHtmlFormatter besides me will find it useful.
The patch is against today's trunk (r8899, source:trunk/trac/mimeview/pygments.py).
Attachments (1)
Change History (6)
by , 15 years ago
Attachment: | HtmlFormatter-rejiggle.diff added |
---|
comment:1 by , 15 years ago
This indeed looks prettier.
Seeing
if c == 'n': c = ''
makes me think you haven't read the TracDev/CodingStyle yet ;-)
Also, what is the speed impact of this change?
comment:2 by , 15 years ago
Milestone: | → 0.12 |
---|
Tentatively set to 0.12, maybe someone could check the performance impact. If no loss, +1.
comment:3 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I ran some tests with ab
against a local Trac instance rendering some python code. The performance was actually faster with the patch. Of course the difference was so small as to not be statistically significant.
Committed the patch with the minor change of
if c == 'n': c = ''
in [9269] since the patch has no performance impact.
comment:5 by , 15 years ago
Owner: | set to |
---|
Refactors GenshiHtmlFormatter.