Changeset - d162de13caec
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-03-18 02:34:45
marcin@python-works.com
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
1 file changed with 15 insertions and 13 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/files.py
Show inline comments
 
@@ -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):
0 comments (0 inline, 0 general)