On Sun, 21 Feb 2016 20:16:48 +0100 Mattias Andrée <maand...@kth.se> wrote:
> On Thu, 28 Jan 2016 16:48:22 +0100 > Markus Wichmann <nullp...@gmx.net> wrote: > > > The two files to be compared are loaded into memory, > > whereby each line is annotated with its line number > > (actually, that's a lie, busybox only saves a hash of > > the line and really, really hopes, there are no > > collisions, but hush). Then both files are sorted by > > line content first and line number second. Then a > > mapping is calculated, that maps each line of the old > > file to its corresponding line in the new one, if any. > > This is done by merging the two files, i. e. > > (pseudocode) > > > > memset(map, -1, sizeof map) > > new file pointer = first new line > > for every old line: > > while (*new file pointer < old line) > > new file pointer ++ > > if (*new file pointer == old line) > > map[old line number] = new line number > > I'm working on implementing it. But there is something > wrong with my code. Would you mind reviewing the > implementation (one function)? > > > https://github.com/maandree/sbase/commit/8c056a724480f19890e01d66c8c13254e2054782#diff-ab603fc6eadf618560316097522fe585R260 I think I got it working. I just need to done an optimisation of the map, which shouldn't be any problem.