http://www.perlmonks.org?node_id=118800


in reply to Re: Merge CIDRs
in thread Merge CIDRs

You need to sort by start address. You're lucky that your input data was already sorted by such.

Also, you have to look for $rs <= $ce + 1 rather than $rs == $ce + 1, or you end up not coalescing things like 0-7 (0.0/3), 4-7 (4.0/2), which should just get swallowed.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Merge CIDRs
by Dominus (Parson) on Oct 15, 2001 at 09:50 UTC
    Says merlyn:
    You need to sort by start address. You're lucky that your input data was already sorted by such.
    No, I'm not. My original problem specification guaranteed sorted input.

    Anyway, those changes wouldn't slow down the program so much that I'd prefer to use the code you posted above. But you said the code above was an order of magnitude faster, not an order of magnitude slower, so I wonder what's up? Someone made a mistake, and I'm less than 50% confident that it was you.

    --
    Mark Dominus
    Perl Paraphernalia