On 14-02-06 21:43:58, Andrew Gregory wrote: > > These part were always ~ 50% different. It's less thant 10 lines of code > > anyway, > > no big deal. Trying to make a common function out of this would result in > > longer > > and more complex code I believe. > > The sync search code is 21 lines. Only 1 line of that is actually > unique to it and can very easily be moved outside of a consolidated > function. The only significant difference between the two is that the > sync search prints lines it can't parse and the local search doesn't. > Neither the script nor the git log explains the disparity and I don't > see any reason to continue it.
I've tried to factor the code into one function and see how it looks. The naive funcion (without much modification from previous version) had 8 lines common to both -Ss and -Qs, 3 different lines, and 6 lines added during the factoring process. No big win if you ask me... It adds one branching in the middle to execute code specific to either -Ss or -Qs. Ugly. Saved 5 lines in total. With a little trick I could remove this condition, thus having in total 0 different line (everything is factored) and 6 additional lines. 1 line is run for nothing in the -Qs case. No big loss, but not very pretty. The function calls is not very elegant either. Saved 8 lines in total. Now we need to decide about what we want: "clarity and efficiency" versus "compactness and no code duplicates". I'll post a patch as soon as possible for you to see how it looks. -- Pierre Neidhardt "Those who believe in astrology are living in houses with foundations of Silly Putty." - Dennis Rawlins, astronomer
