From: Ben Pfaff Date: Tue, 23 Dec 2008 23:04:54 +0000 (-0800) Subject: Inline flow_compare() and flow_hash(), for performance. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c501bd76ee790ff7cf3c22625da7cf2257cf5a56;p=openvswitch Inline flow_compare() and flow_hash(), for performance. --- diff --git a/lib/flow.c b/lib/flow.c index 8b05b0a5..7ba8ee4e 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -220,18 +220,3 @@ flow_print(FILE *stream, const struct flow *flow) IP_ARGS(&flow->nw_src), IP_ARGS(&flow->nw_dst), ntohs(flow->tp_src), ntohs(flow->tp_dst)); } - -int -flow_compare(const struct flow *a, const struct flow *b) -{ - return memcmp(a, b, sizeof *a); -} - -size_t -flow_hash(const struct flow *flow, uint32_t basis) -{ - BUILD_ASSERT_DECL(!(sizeof *flow % sizeof(uint32_t))); - return hash_lookup3((const uint32_t *) flow, - sizeof *flow / sizeof(uint32_t), basis); -} - diff --git a/lib/flow.h b/lib/flow.h index 1d7becf3..f0736526 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -35,6 +35,8 @@ #include #include +#include +#include "hash.h" #include "util.h" struct ofpbuf; @@ -60,7 +62,21 @@ BUILD_ASSERT_DECL(sizeof(struct flow) == 32); int flow_extract(struct ofpbuf *, uint16_t in_port, struct flow *); void flow_print(FILE *, const struct flow *); -int flow_compare(const struct flow *, const struct flow *); -size_t flow_hash(const struct flow *, uint32_t basis); +static inline int flow_compare(const struct flow *, const struct flow *); +static inline size_t flow_hash(const struct flow *, uint32_t basis); + +static inline int +flow_compare(const struct flow *a, const struct flow *b) +{ + return memcmp(a, b, sizeof *a); +} + +static inline size_t +flow_hash(const struct flow *flow, uint32_t basis) +{ + BUILD_ASSERT_DECL(!(sizeof *flow % sizeof(uint32_t))); + return hash_lookup3((const uint32_t *) flow, + sizeof *flow / sizeof(uint32_t), basis); +} #endif /* flow.h */