Re: Cleaning up Differ



2009/6/7 Piotr Piastucki <leech miranda gmail com>:
> I am a bit surprised that the patch is not self-explanatory, because the
> code in diffutil is quite simple after all, but here is the info you
> requested:

Parts 2 and 3 are indeed obvious, given that part 1 is correct.

> 1) block is not need if
> len(using[0])==0 OR len(using[1])==0
> because of:
> ...
>           block = self._merge_blocks( using, base_seq, high_seq, block)
>
>           if len(using[0])==0:
>               assert len(using[1])==1
>               yield None, using[1][0]
>           elif len(using[1])==0:
>               assert len(using[0])==1
>               yield using[0][0], None
>           else:
> ...
> so moving the call here does not change anything:
> ...
>               yield using[0][0], None
>           else:
>               block = self._merge_blocks( using, base_seq, high_seq, block)
> ...

This isn't (by itself) true. The call you're moving assigns to block,
which is used in subsequent calls to _merge_blocks(). In order to not
change behaviour, either the value of block needs to be unchanged by
the cases that you're now skipping, or the changes to block need to be
irrelevant. The commit message should include some brief explanation
about why this is the case.

Kai


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]