summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw@src.gnome.org>2014-05-11 15:34:53 +0800
committerTing-Wei Lan <lantw@src.gnome.org>2014-05-11 15:46:22 +0800
commitf9c0af9589ffb342ca38cd925fa3bbbc46284ad3 (patch)
treea216c18fbc468d5fb7b067d95dd8d1783347b6cf
parent75de813fbc40e897f212abc994b127542296dc78 (diff)
downloadgsoc2013-libgnome-autoar-f9c0af9589ffb342ca38cd925fa3bbbc46284ad3.tar
gsoc2013-libgnome-autoar-f9c0af9589ffb342ca38cd925fa3bbbc46284ad3.tar.gz
gsoc2013-libgnome-autoar-f9c0af9589ffb342ca38cd925fa3bbbc46284ad3.tar.bz2
gsoc2013-libgnome-autoar-f9c0af9589ffb342ca38cd925fa3bbbc46284ad3.tar.lz
gsoc2013-libgnome-autoar-f9c0af9589ffb342ca38cd925fa3bbbc46284ad3.tar.xz
gsoc2013-libgnome-autoar-f9c0af9589ffb342ca38cd925fa3bbbc46284ad3.tar.zst
gsoc2013-libgnome-autoar-f9c0af9589ffb342ca38cd925fa3bbbc46284ad3.zip
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.
-rw-r--r--gnome-autoar/autoar-extract.c14
-rw-r--r--tests/test-extract.c8
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