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_livesync.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'ot_livesync.c') diff --git a/ot_livesync.c b/ot_livesync.c index 1b1efe0..b447e83 100644 --- a/ot_livesync.c +++ b/ot_livesync.c @@ -94,10 +94,11 @@ static void livesync_issuepacket( ) { /* Inform live sync about whats going on. */ void livesync_tell( ot_hash * const info_hash, const ot_peer * const peer ) { - memmove( livesync_outbuffer_pos , info_hash, sizeof(ot_hash)); - memmove( livesync_outbuffer_pos + sizeof(ot_hash), peer, sizeof(ot_peer)); - - livesync_outbuffer_pos += sizeof(ot_hash) + sizeof(ot_peer); + int i; + for(i=0;i<20;i+=4) WRITE32(livesync_outbuffer_pos+=4,0,READ32(info_hash,i)); + WRITE32(livesync_outbuffer_pos+=4,0,READ32(peer,0)); + WRITE32(livesync_outbuffer_pos+=4,0,READ32(peer,4)); + if( livesync_outbuffer_pos >= livesync_outbuffer_highwater ) livesync_issuepacket(); } @@ -146,7 +147,7 @@ static void * livesync_worker( void * args ) { ot_peer *peer = (ot_peer*)(livesync_inbuffer + off + sizeof(ot_hash)); ot_hash *hash = (ot_hash*)(livesync_inbuffer + off); - if( OT_FLAG(peer) & PEER_FLAG_STOPPED ) + if( OT_PEERFLAG(peer) & PEER_FLAG_STOPPED ) remove_peer_from_torrent(hash, peer, NULL, FLAG_MCA); else add_peer_to_torrent( hash, peer WANT_SYNC_PARAM(1)); -- cgit v1.2.3