From 08c71627839a9134367db354c8255f7a720e1ff3 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sat, 6 Dec 2008 18:46:00 +0000 Subject: Renamed OT_FLAG to OT_PEERFLAG to make code easier to read Introduced READ16/32 and WRITE16/32 makros to abstract loading/storing from unaligned addresses away on cpu's that can actually load/store everywhere Removed all unnecessary memmoves, especially where it only moved 6 bytes in inner loop. I replaced them with WRITE16/32(READ16/32()) makros --- ot_fullscrape.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ot_fullscrape.c') diff --git a/ot_fullscrape.c b/ot_fullscrape.c index dfad640..5f61afd 100644 --- a/ot_fullscrape.c +++ b/ot_fullscrape.c @@ -113,7 +113,7 @@ static int fullscrape_increase( int *iovec_entries, struct iovec **iovector, } static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tasktype mode ) { - int bucket; + int bucket,i; char *r, *re; #ifdef WANT_COMPRESSION_GZIP char compress_buffer[OT_SCRAPE_MAXENTRYLEN]; @@ -163,7 +163,7 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas /* push hash as bencoded string */ *r++='2'; *r++='0'; *r++=':'; - memmove( r, hash, 20 ); r+=20; + for(i=0;i<20;i+=4) WRITE32(r+=4,0,READ32(hash,i)); /* push rest of the scrape string */ r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee", peer_list->seed_count, peer_list->down_count, peer_list->peer_count-peer_list->seed_count ); @@ -174,7 +174,7 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas r += sprintf( r, ":%zd:%zd\n", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count ); break; case TASK_FULLSCRAPE_TPB_BINARY: - memmove( r, hash, 20 ); r+=20; + for(i=0;i<20;i+=4) WRITE32(r+=4,0,READ32(hash,i)); *(uint32_t*)r++ = htonl( (uint32_t)peer_list->seed_count ); *(uint32_t*)r++ = htonl( (uint32_t)( peer_list->peer_count-peer_list->seed_count) ); break; -- cgit v1.2.3