mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 08:27:22 +03:00
Don't copy style when removing decorations if there's no need to
It saves a lot of memory for very long paragraphs with no decoration style.
This commit is contained in:
parent
76c3a47607
commit
005d9a3c9f
@ -316,11 +316,15 @@ class ParentBox(Box):
|
|||||||
|
|
||||||
def _remove_decoration(self, start, end):
|
def _remove_decoration(self, start, end):
|
||||||
if start or end:
|
if start or end:
|
||||||
|
old_style = self.style
|
||||||
self.style = self.style.copy()
|
self.style = self.style.copy()
|
||||||
if start:
|
if start:
|
||||||
self._reset_spacing('top')
|
self._reset_spacing('top')
|
||||||
if end:
|
if end:
|
||||||
self._reset_spacing('bottom')
|
self._reset_spacing('bottom')
|
||||||
|
if (start or end) and old_style == self.style:
|
||||||
|
# Don't copy style if there's no need to, save some memory
|
||||||
|
self.style = old_style
|
||||||
|
|
||||||
def copy_with_children(self, new_children, is_start=True, is_end=True):
|
def copy_with_children(self, new_children, is_start=True, is_end=True):
|
||||||
"""Create a new equivalent box with given ``new_children``."""
|
"""Create a new equivalent box with given ``new_children``."""
|
||||||
|
Loading…
Reference in New Issue
Block a user