Re: [RFC PATCH v2 2/5] linear-assignment.c: split up compute_assignment() function

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

 



On Fri, Dec 10, 2021 at 01:30:39PM +0100, Ævar Arnfjörð Bjarmason wrote:

> Split up the the long compute_assignment() function to make it easier
> to reason about, particularly when it comes to what variables are used
> later, and which aren't.

OK, this refactor seems reasonable. I don't know enough about the
linear-assignment algorithm to know whether the names you've picked are
meaningful.

> +void compute_assignment(int column_count, int row_count,
> +			int *cost,
> +			int *column2row, int *row2column)
> +{
> +	int *v;
> +	int *free_row, free_count = 0, saved_free_count;
> +
> +	assert(column_count > 1);
> +	memset(column2row, -1, sizeof(int) * column_count);
> +	memset(row2column, -1, sizeof(int) * row_count);
> +	ALLOC_ARRAY(v, column_count);

So this is the code where we would have kept the column_count check and
zero'd column2row and row2column, had we not moved it in the previous
commit. I actually think it would fit fine here in the refactored
compute_assignment() if you had left it.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux