clean up: rename get_order() to merge() and mark static

No other function than mergesort_ranges() can use the merge(), so calling
it with rather generic name and making it static seems right to me.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-12-09 23:20:46 +00:00
parent bd5ee58a3f
commit 82df7c98d4
2 changed files with 3 additions and 7 deletions

View file

@ -232,8 +232,6 @@ unsigned long int ret_touched(struct range_t r);
unsigned long int ret_tc(struct range_t r); unsigned long int ret_tc(struct range_t r);
unsigned long int ret_tcperc(struct range_t r); unsigned long int ret_tcperc(struct range_t r);
void field_selector(char c); void field_selector(char c);
int get_order(struct range_t *__restrict left, struct range_t *__restrict right)
__attribute__ ((nonnull(1, 2)));
void mergesort_ranges(struct range_t *__restrict orig, int size, void mergesort_ranges(struct range_t *__restrict orig, int size,
struct range_t *__restrict temp) struct range_t *__restrict temp)
__attribute__ ((nonnull(1, 3))); __attribute__ ((nonnull(1, 3)));

View file

@ -197,11 +197,9 @@ void field_selector(char c)
/*! \brief Perform requested sorting. /*! \brief Perform requested sorting.
* \param left The left side of the merge sort. * \param left The left side of the merge sort.
* \param right The right side of the merge sort. * \param right The right side of the merge sort.
* FIXME: This function should be marked as static.
* FIXME: Really horribly named indirection about which function is in use.
* \return Relevant for merge sort decision. * \return Relevant for merge sort decision.
*/ */
int get_order(struct range_t *restrict left, struct range_t *restrict right) static int merge(struct range_t *restrict left, struct range_t *restrict right)
{ {
int i, len, ret; int i, len, ret;
unsigned long int lint, rint; unsigned long int lint, rint;
@ -256,7 +254,7 @@ void mergesort_ranges(struct range_t *restrict orig, int size,
for (left = 0; left < size; left++) { for (left = 0; left < size; left++) {
hold = *(orig + left); hold = *(orig + left);
for (right = left - 1; 0 <= right; right--) { for (right = left - 1; 0 <= right; right--) {
if (get_order((orig + right), &hold)) { if (merge((orig + right), &hold)) {
break; break;
} }
*(orig + right + 1) = *(orig + right); *(orig + right + 1) = *(orig + right);
@ -274,7 +272,7 @@ void mergesort_ranges(struct range_t *restrict orig, int size,
i = 0; i = 0;
while (left < size / 2 && right < size) { while (left < size / 2 && right < size) {
if (get_order((orig + left), (orig + right))) { if (merge((orig + left), (orig + right))) {
*(temp + i) = *(orig + left); *(temp + i) = *(orig + left);
left++; left++;
} else { } else {