From: Vsevolod Stakhov Date: Fri, 18 Feb 2011 15:40:46 +0000 (+0300) Subject: Optimize DNS parsing. X-Git-Tag: 0.3.7~23 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c22c8be47f7ef8e3018dbb301f65f512b4e83535;p=rspamd.git Optimize DNS parsing. Suggested by: Igor Sysoev --- diff --git a/src/dns.c b/src/dns.c index 4070c4905..82c796c1e 100644 --- a/src/dns.c +++ b/src/dns.c @@ -755,8 +755,8 @@ end: return TRUE; } -#define GET16(x) do {if (*remain < sizeof (guint16)) {goto err;} memcpy (&(x), p, sizeof (guint16)); (x) = ntohs ((x)); p += sizeof (guint16); *remain -= sizeof (guint16); } while(0) -#define GET32(x) do {if (*remain < sizeof (guint32)) {goto err;} memcpy (&(x), p, sizeof (guint32)); (x) = ntohl ((x)); p += sizeof (guint32); *remain -= sizeof (guint32); } while(0) +#define GET16(x) do {(x) = ((*p) << 8) + *(p + 1); p += sizeof (guint16); *remain -= sizeof (guint16); } while(0) +#define GET32(x) do {(x) = ((*p) << 24) + ((*(p + 1)) << 16) + ((*(p + 2)) << 8) + *(p + 3); p += sizeof (guint32); *remain -= sizeof (guint32); } while(0) static gint dns_parse_rr (guint8 *in, union rspamd_reply_element *elt, guint8 **pos, struct rspamd_dns_reply *rep, gint *remain)