summaryrefslogtreecommitdiff
path: root/ot_vector.c
diff options
context:
space:
mode:
authorerdgeist <>2008-12-06 18:46:00 +0000
committererdgeist <>2008-12-06 18:46:00 +0000
commit08c71627839a9134367db354c8255f7a720e1ff3 (patch)
treeb429abf6b3c26c7f851b522f5d4fb6797ad02d29 /ot_vector.c
parenta4ed31d517f77a21afe12918a9cb256489daac74 (diff)
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
Diffstat (limited to 'ot_vector.c')
-rw-r--r--ot_vector.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/ot_vector.c b/ot_vector.c
index 7d2a1a9..154d1c8 100644
--- a/ot_vector.c
+++ b/ot_vector.c
@@ -16,9 +16,6 @@
16#include "uint32.h" 16#include "uint32.h"
17#include "uint16.h" 17#include "uint16.h"
18 18
19#define READ16(addr,offs) ((int16_t)uint16_read((offs)+(uint8_t*)(addr)))
20#define READ32(addr,offs) ((int32_t)uint32_read((offs)+(uint8_t*)(addr)))
21
22static int vector_compare_peer(const void *peer1, const void *peer2 ) { 19static int vector_compare_peer(const void *peer1, const void *peer2 ) {
23 int32_t cmp = READ32(peer1,0) - READ32(peer2,0); 20 int32_t cmp = READ32(peer1,0) - READ32(peer2,0);
24 if (cmp == 0) cmp = READ16(peer1,4) - READ16(peer2,4); 21 if (cmp == 0) cmp = READ16(peer1,4) - READ16(peer2,4);
@@ -166,7 +163,7 @@ int vector_remove_peer( ot_vector *vector, ot_peer *peer ) {
166 match = binary_search_peer( peer, vector->data, vector->size, &exactmatch ); 163 match = binary_search_peer( peer, vector->data, vector->size, &exactmatch );
167 if( !exactmatch ) return 0; 164 if( !exactmatch ) return 0;
168 165
169 exactmatch = ( OT_FLAG( match ) & PEER_FLAG_SEEDING ) ? 2 : 1; 166 exactmatch = ( OT_PEERFLAG( match ) & PEER_FLAG_SEEDING ) ? 2 : 1;
170 memmove( match, match + 1, sizeof(ot_peer) * ( end - match - 1 ) ); 167 memmove( match, match + 1, sizeof(ot_peer) * ( end - match - 1 ) );
171 168
172 vector->size--; 169 vector->size--;