# HG changeset patch # User Marcin Kuzminski # Date 2011-03-18 02:34:45 # Node ID d162de13caecbe5e131425a1e55e0105ca402880 # Parent 6f87e177f0570faf0505c1186ad09ffe3960558b memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit. reduces memory consumption a lot on binary files ! Additionally checking for binary before the size gives little more performance as well diff --git a/rhodecode/controllers/files.py b/rhodecode/controllers/files.py --- a/rhodecode/controllers/files.py +++ b/rhodecode/controllers/files.py @@ -244,27 +244,29 @@ class FilesController(BaseRepoController return diff.raw_diff() elif c.action == 'diff': - diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2), + + if node1.is_binary or node2.is_binary: + c.cur_diff = _('Binary file') + elif node1.size > self.cut_off_limit or node2.size > self.cut_off_limit: + c.cur_diff = _('Diff is too big to display') + else: + diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2), format='gitdiff') - - if node1.size > self.cut_off_limit or node2.size > self.cut_off_limit: - c.cur_diff = _('Diff is to big to display') - elif node1.is_binary or node2.is_binary: - c.cur_diff = _('Binary file') - else: c.cur_diff = diff.as_html() else: - diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2), - format='gitdiff') + #default option - if node1.size > self.cut_off_limit or node2.size > self.cut_off_limit: - c.cur_diff = _('Diff is to big to display') - elif node1.is_binary or node2.is_binary: + if node1.is_binary or node2.is_binary: c.cur_diff = _('Binary file') + elif node1.size > self.cut_off_limit or node2.size > self.cut_off_limit: + c.cur_diff = _('Diff is too big to display') else: + diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2), + format='gitdiff') c.cur_diff = diff.as_html() - if not c.cur_diff: c.no_changes = True + if not c.cur_diff: + c.no_changes = True return render('files/file_diff.html') def _get_history(self, repo, node, f_path):