From f9c0af9589ffb342ca38cd925fa3bbbc46284ad3 Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Sun, 11 May 2014 15:34:53 +0800 Subject: AutoarExtract: Prevent unneeded floating operations Fractions are not always needed, so I removed change it the same as AutoarCreate to the prevent unneeded calculation and function calls. --- gnome-autoar/autoar-extract.c | 14 ++++++-------- tests/test-extract.c | 8 ++++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/gnome-autoar/autoar-extract.c b/gnome-autoar/autoar-extract.c index bfdfd9d..65a49d0 100644 --- a/gnome-autoar/autoar-extract.c +++ b/gnome-autoar/autoar-extract.c @@ -816,10 +816,8 @@ autoar_extract_signal_progress (AutoarExtract *arextract) if (mtime - arextract->priv->notify_last >= arextract->priv->notify_interval) { autoar_common_g_signal_emit (arextract, arextract->priv->in_thread, autoar_extract_signals[PROGRESS], 0, - ((double)(arextract->priv->completed_size)) / - ((double)(arextract->priv->size)), - ((double)(arextract->priv->completed_files)) / - ((double)(arextract->priv->files))); + arextract->priv->completed_size, + arextract->priv->completed_files); arextract->priv->notify_last = mtime; } } @@ -1394,8 +1392,8 @@ autoar_extract_class_init (AutoarExtractClass *klass) /** * AutoarExtract::progress: * @arextract: the #AutoarExtract - * @fraction_size: fraction of size has been written to disk - * @fraction_files: fraction of number of files have been written to disk + * @completed_size: bytes has been written to disk + * @completed_files: number of files have been written to disk * * This signal is used to report progress of creating archives. **/ @@ -1407,8 +1405,8 @@ autoar_extract_class_init (AutoarExtractClass *klass) g_cclosure_marshal_generic, G_TYPE_NONE, 2, - G_TYPE_DOUBLE, - G_TYPE_DOUBLE); + G_TYPE_UINT64, + G_TYPE_UINT); /** * AutoarExtract::cancelled: diff --git a/tests/test-extract.c b/tests/test-extract.c index 64876d8..197eca8 100644 --- a/tests/test-extract.c +++ b/tests/test-extract.c @@ -28,13 +28,13 @@ my_handler_decide_dest (AutoarExtract *arextract, static void my_handler_progress (AutoarExtract *arextract, - gdouble fraction_size, - gdouble fraction_files, + guint64 completed_size, + guint completed_files, gpointer data) { g_print ("\rProgress: Archive Size %.2lf %%, Files %.2lf %%", - fraction_size * 100, - fraction_files * 100); + ((double)(completed_size)) * 100 / autoar_extract_get_size (arextract), + ((double)(completed_files)) * 100 / autoar_extract_get_files (arextract)); } static void -- cgit v1.2.3