Commit e47d8303 authored by Julien Muchembled's avatar Julien Muchembled

Speed up TemplateTool.getFilterDiff

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40066 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 457115ac
...@@ -633,13 +633,13 @@ class TemplateTool (BaseTool): ...@@ -633,13 +633,13 @@ class TemplateTool (BaseTool):
""" """
Return list of scripts usable to filter diff Return list of scripts usable to filter diff
""" """
# XXX, the or [] should not be there, the preference tool is # XXX, the "or ()" should not be there, the preference tool is
# inconsistent, the called method should not return None when # inconsistent, the called method should not return None when
# nothing is selected # nothing is selected
script_id_list = self.getPortalObject().portal_preferences\ portal = self.getPortalObject()
.getPreferredDiffFilterScriptIdList() or [] script_id_list = portal.portal_preferences\
.getPreferredDiffFilterScriptIdList() or ()
return [getattr(self, x) for x in script_id_list] return [getattr(portal, x) for x in script_id_list]
def getFilteredDiffAsHTML(self, diff): def getFilteredDiffAsHTML(self, diff):
""" """
...@@ -653,11 +653,13 @@ class TemplateTool (BaseTool): ...@@ -653,11 +653,13 @@ class TemplateTool (BaseTool):
""" """
diff_file_object = DiffFile(diff) diff_file_object = DiffFile(diff)
diff_block_list = diff_file_object.getModifiedBlockList() diff_block_list = diff_file_object.getModifiedBlockList()
if len(diff_block_list): if diff_block_list:
for script in self.getDiffFilterScriptList(): script_list = self.getDiffFilterScriptList()
for block, line_tuple in diff_block_list: for block, line_tuple in diff_block_list:
for script in script_list:
if script(line_tuple[0], line_tuple[1]): if script(line_tuple[0], line_tuple[1]):
diff_file_object.children.remove(block) diff_file_object.children.remove(block)
break
# XXX-Aurel : this method should return a text diff but # XXX-Aurel : this method should return a text diff but
# DiffFile does not provide yet such feature # DiffFile does not provide yet such feature
return diff_file_object return diff_file_object
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment