From 69a111a7394a5d1be41817012c2542e301c4fc60 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 31 Aug 2018 23:17:27 +0200 Subject: [PATCH] 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 --- src/ccutil/helpers.h | 12 ------------ src/textord/topitch.cpp | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/ccutil/helpers.h b/src/ccutil/helpers.h index f27e29e96..dcb6d1331 100644 --- a/src/ccutil/helpers.h +++ b/src/ccutil/helpers.h @@ -101,18 +101,6 @@ template 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); diff --git a/src/textord/topitch.cpp b/src/textord/topitch.cpp index 7d71c253d..6cd0bcf07 100644 --- a/src/textord/topitch.cpp +++ b/src/textord/topitch.cpp @@ -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(arg1) - + *reinterpret_cast(arg2); + if (diff > 0) { + return 1; + } else if (diff < 0) { + return -1; + } else { + return 0; + } +} + /********************************************************************** * compute_fixed_pitch *