flowbits: optimize set and remove

pull/1872/head
Victor Julien 11 years ago
parent c467c39b61
commit 0dbbe016d6

@ -105,31 +105,25 @@ static void FlowBitRemove(Flow *f, uint16_t idx)
void FlowBitSetNoLock(Flow *f, uint16_t idx) void FlowBitSetNoLock(Flow *f, uint16_t idx)
{ {
FlowBit *fb = FlowBitGet(f, idx);
if (fb == NULL) {
FlowBitAdd(f, idx); FlowBitAdd(f, idx);
}
} }
void FlowBitSet(Flow *f, uint16_t idx) void FlowBitSet(Flow *f, uint16_t idx)
{ {
FLOWLOCK_WRLOCK(f); FLOWLOCK_WRLOCK(f);
FlowBitSetNoLock(f, idx); FlowBitAdd(f, idx);
FLOWLOCK_UNLOCK(f); FLOWLOCK_UNLOCK(f);
} }
void FlowBitUnsetNoLock(Flow *f, uint16_t idx) void FlowBitUnsetNoLock(Flow *f, uint16_t idx)
{ {
FlowBit *fb = FlowBitGet(f, idx);
if (fb != NULL) {
FlowBitRemove(f, idx); FlowBitRemove(f, idx);
}
} }
void FlowBitUnset(Flow *f, uint16_t idx) void FlowBitUnset(Flow *f, uint16_t idx)
{ {
FLOWLOCK_WRLOCK(f); FLOWLOCK_WRLOCK(f);
FlowBitUnsetNoLock(f, idx); FlowBitRemove(f, idx);
FLOWLOCK_UNLOCK(f); FLOWLOCK_UNLOCK(f);
} }

Loading…
Cancel
Save