Clean use of qsort function sort_floats

It is only used in textord/topitch.cpp, so move it into that file.

Remove also the inline attribute as it has not effect here and
update the type casts to fix some compiler warnings from clang.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2018-08-31 23:17:27 +02:00
parent e4b9cfffcb
commit 69a111a739
2 changed files with 13 additions and 12 deletions

View File

@ -101,18 +101,6 @@ template<typename T> inline void Swap(T* p1, T* p2) {
*p1 = tmp;
}
// qsort function to sort 2 floats.
inline int sort_floats(const void *arg1, const void *arg2) {
float diff = *((float *) arg1) - *((float *) arg2);
if (diff > 0) {
return 1;
} else if (diff < 0) {
return -1;
} else {
return 0;
}
}
// return the smallest multiple of block_size greater than or equal to n.
inline int RoundUp(int n, int block_size) {
return block_size * ((n + block_size - 1) / block_size);

View File

@ -60,6 +60,19 @@ EXTERN double_VAR (textord_balance_factor, 1.0,
#define BLOCK_STATS_CLUSTERS 10
#define MAX_ALLOWED_PITCH 100 //max pixel pitch.
// qsort function to sort 2 floats.
static int sort_floats(const void *arg1, const void *arg2) {
float diff = *reinterpret_cast<const float*>(arg1) -
*reinterpret_cast<const float*>(arg2);
if (diff > 0) {
return 1;
} else if (diff < 0) {
return -1;
} else {
return 0;
}
}
/**********************************************************************
* compute_fixed_pitch
*