[meld] Refactor change_sequence
- From: Kai Willadsen <kaiw src gnome org>
- To: svn-commits-list gnome org
- Subject: [meld] Refactor change_sequence
- Date: Tue, 30 Jun 2009 08:07:07 +0000 (UTC)
commit 6caa1317c21b39ba00c8338159d088b754d17cdd
Author: Kai Willadsen <kai willadsen gmail com>
Date: Tue Jun 2 15:39:11 2009 +1000
Refactor change_sequence
Differ only has two internal diffs that need to be updated on sequence
change. The updating logic can be simplified by enumerating conditions
for each sequence.
diffutil.py | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/diffutil.py b/diffutil.py
index 6314659..43cdc4f 100644
--- a/diffutil.py
+++ b/diffutil.py
@@ -68,14 +68,11 @@ class Differ(object):
self.diffs = [[], []]
def change_sequence(self, sequence, startidx, sizechange, texts):
- assert sequence in (0,1,2)
- if sequence != 1: #0 or 2
- which = sequence / 2
- self._change_sequence(which, sequence, startidx, sizechange, texts)
- else: # sequence==1:
+ assert sequence in (0, 1, 2)
+ if sequence == 0 or sequence == 1:
self._change_sequence(0, sequence, startidx, sizechange, texts)
- if self.num_sequences == 3:
- self._change_sequence(1, sequence, startidx, sizechange, texts)
+ if sequence == 2 or (sequence == 1 and self.num_sequences == 3):
+ self._change_sequence(1, sequence, startidx, sizechange, texts)
self.seqlength[sequence] += sizechange
def _locate_chunk(self, whichdiffs, sequence, line):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]