Mercurial > kallithea
diff rhodecode/controllers/files.py @ 1149:d162de13caec beta
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
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 18 Mar 2011 02:34:45 +0100 |
parents | 82344ce0a892 |
children | 0c5629ce52e4 |
line wrap: on
line diff
--- a/rhodecode/controllers/files.py Thu Mar 17 21:48:00 2011 +0100 +++ b/rhodecode/controllers/files.py Fri Mar 18 02:34:45 2011 +0100 @@ -244,27 +244,29 @@ 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):