openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #18178
[Merge] lp:~googol/openlp/render into lp:openlp
Andreas Preikschat has proposed merging lp:~googol/openlp/render into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~googol/openlp/render/+merge/137446
- when a verse appears more than once do not render the verse again, instead use the already rendered one to improve performance
Thanks to gushie who had the idea. Hahahaha, I bet he does not remember.
--
https://code.launchpad.net/~googol/openlp/render/+merge/137446
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/render into lp:openlp.
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2012-12-01 07:57:54 +0000
+++ openlp/core/lib/serviceitem.py 2012-12-02 20:43:30 +0000
@@ -181,8 +181,19 @@
self.themedata, self.main, self.footer = self.renderer.pre_render()
if self.service_item_type == ServiceItemType.Text:
log.debug(u'Formatting slides: %s' % self.title)
+ # Save rendered pages to this dict. In the case that a slide is used
+ # twice we can use the pages saved to the dict instead of rendering
+ # them again.
+ previous_pages = {}
for slide in self._raw_frames:
- pages = self.renderer.format_slide(slide[u'raw_slide'], self)
+ verse_tag = slide[u'verseTag']
+ if verse_tag in previous_pages and \
+ previous_pages[verse_tag][0] == slide[u'raw_slide']:
+ pages = previous_pages[verse_tag][1]
+ else:
+ pages = \
+ self.renderer.format_slide(slide[u'raw_slide'], self)
+ previous_pages[verse_tag] = (slide[u'raw_slide'], pages)
for page in pages:
page = page.replace(u'<br>', u'{br}')
html = expand_tags(cgi.escape(page.rstrip()))
@@ -190,7 +201,7 @@
u'title': clean_tags(page),
u'text': clean_tags(page.rstrip()),
u'html': html.replace(u'&nbsp;', u' '),
- u'verseTag': slide[u'verseTag']
+ u'verseTag': verse_tag
})
elif self.service_item_type == ServiceItemType.Image or \
self.service_item_type == ServiceItemType.Command:
Follow ups