From d6271bf00c0c4e1636959b303a497d86816f70f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 5 Jan 2008 13:29:01 +0000 Subject: [PATCH] Re-implement GCD iteratively. Fix unused function warning. --- include/vlc_common.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/vlc_common.h b/include/vlc_common.h index fa177d538b..a467273876 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -670,10 +670,15 @@ __vlc_gc_init( gc_object_t * p_gc, void (*pf_destructor)( gc_object_t * ), # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) #endif -static int64_t GCD( int64_t a, int64_t b ) +static inline int64_t GCD( int64_t a, int64_t b ) { - if( b ) return GCD( b, a % b ); - else return a; + while( b ) + { + int64_t c = a % b; + a = b; + b = c; + } + return a; } /* function imported from libavutil/common.h */ -- 2.20.1