forked from openlp/openlp
when a verse appears more than once do not render the verse again, instead use the already rendered one to improve performance
This commit is contained in:
parent
42dec84a31
commit
b226364559
@ -180,8 +180,19 @@ class ServiceItem(object):
|
|||||||
self.themedata, self.main, self.footer = self.renderer.pre_render()
|
self.themedata, self.main, self.footer = self.renderer.pre_render()
|
||||||
if self.service_item_type == ServiceItemType.Text:
|
if self.service_item_type == ServiceItemType.Text:
|
||||||
log.debug(u'Formatting slides: %s' % self.title)
|
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:
|
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:
|
for page in pages:
|
||||||
page = page.replace(u'<br>', u'{br}')
|
page = page.replace(u'<br>', u'{br}')
|
||||||
html = expand_tags(cgi.escape(page.rstrip()))
|
html = expand_tags(cgi.escape(page.rstrip()))
|
||||||
@ -189,7 +200,7 @@ class ServiceItem(object):
|
|||||||
u'title': clean_tags(page),
|
u'title': clean_tags(page),
|
||||||
u'text': clean_tags(page.rstrip()),
|
u'text': clean_tags(page.rstrip()),
|
||||||
u'html': html.replace(u'&nbsp;', u' '),
|
u'html': html.replace(u'&nbsp;', u' '),
|
||||||
u'verseTag': slide[u'verseTag']
|
u'verseTag': verse_tag
|
||||||
})
|
})
|
||||||
elif self.service_item_type == ServiceItemType.Image or \
|
elif self.service_item_type == ServiceItemType.Image or \
|
||||||
self.service_item_type == ServiceItemType.Command:
|
self.service_item_type == ServiceItemType.Command:
|
||||||
|
Loading…
Reference in New Issue
Block a user