aboutsummaryrefslogtreecommitdiffstats
path: root/progress.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2003-07-08 16:54:53 +0000
committerWayne Davison <wayned@samba.org>2003-07-08 16:54:53 +0000
commit1c8162a921cbae803b3bf375fda4aa7916bcfc68 (patch)
tree3ad3ffa1a264afcf657481f8daa0d2f37de4a757 /progress.c
parent16417f8b9d1947f4efbe540ee6983feba2ebc21c (diff)
downloadandroid_external_rsync-1c8162a921cbae803b3bf375fda4aa7916bcfc68.tar.gz
android_external_rsync-1c8162a921cbae803b3bf375fda4aa7916bcfc68.tar.bz2
android_external_rsync-1c8162a921cbae803b3bf375fda4aa7916bcfc68.zip
Optimized show_progress() to reduce the calls to gettimeofday() when
am_server is set. No need to check do_progress here anymore, since we aren't called if do_progress isn't set.
Diffstat (limited to 'progress.c')
-rw-r--r--progress.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/progress.c b/progress.c
index e842b9a9..083b6df2 100644
--- a/progress.c
+++ b/progress.c
@@ -79,39 +79,43 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
void end_progress(OFF_T size)
{
- extern int do_progress, am_server;
+ extern int am_server;
- if (do_progress && !am_server) {
- struct timeval now;
- gettimeofday(&now, NULL);
- rprint_progress(size, size, &now, True);
+ if (!am_server) {
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ rprint_progress(size, size, &now, True);
}
last_ofs = 0;
- start_ofs = 0;
- print_time.tv_sec = print_time.tv_usec = 0;
- start_time.tv_sec = start_time.tv_usec = 0;
+ start_ofs = 0;
+ print_time.tv_sec = print_time.tv_usec = 0;
+ start_time.tv_sec = start_time.tv_usec = 0;
}
void show_progress(OFF_T ofs, OFF_T size)
{
- extern int do_progress, am_server;
- struct timeval now;
+ extern int am_server;
+ struct timeval now;
- gettimeofday(&now, NULL);
-
- if (!start_time.tv_sec && !start_time.tv_usec) {
- start_time.tv_sec = now.tv_sec;
- start_time.tv_usec = now.tv_usec;
- start_ofs = ofs;
- }
+ if (!start_time.tv_sec) {
+ gettimeofday(&now, NULL);
+ start_time.tv_sec = now.tv_sec;
+ start_time.tv_usec = now.tv_usec;
+ start_ofs = ofs;
+ if (am_server)
+ return;
+ }
+ else {
+ if (am_server)
+ return;
+ gettimeofday(&now, NULL);
+ }
- if (do_progress
- && !am_server
- && ofs > last_ofs + 1000
- && msdiff(&print_time, &now) > 250) {
- rprint_progress(ofs, size, &now, False);
- last_ofs = ofs;
- print_time.tv_sec = now.tv_sec;
- print_time.tv_usec = now.tv_usec;
+ if (ofs > last_ofs + 1000
+ && msdiff(&print_time, &now) > 250) {
+ rprint_progress(ofs, size, &now, False);
+ last_ofs = ofs;
+ print_time.tv_sec = now.tv_sec;
+ print_time.tv_usec = now.tv_usec;
}
}