diff options
| author | Shulhan <ms@kilabit.info> | 2023-09-10 23:09:44 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-09-11 02:26:33 +0700 |
| commit | d22b0b4af8200430ab7cdfd85ff8e702b3e06fcd (patch) | |
| tree | 345f82338b9fe313adc16dbe1f76cfccc9d7375d | |
| parent | eba35999e6e88c302bd202a23a0bdaf664f7b788 (diff) | |
| download | pakakeh.go-d22b0b4af8200430ab7cdfd85ff8e702b3e06fcd.tar.xz | |
lib/spf: realign struct for better size allocation
The realignment reduce the cost of the following struct,
* directive: from 32 to 24 bytes (-8)
* macro: from 64 to 56 bytes (-8)
* Result: from 224 to 216 bytes (-8)
| -rw-r--r-- | lib/spf/directive.go | 2 | ||||
| -rw-r--r-- | lib/spf/macro.go | 14 | ||||
| -rw-r--r-- | lib/spf/result.go | 9 |
3 files changed, 16 insertions, 9 deletions
diff --git a/lib/spf/directive.go b/lib/spf/directive.go index 417384f1..45a0c66a 100644 --- a/lib/spf/directive.go +++ b/lib/spf/directive.go @@ -25,7 +25,7 @@ const ( ) type directive struct { - qual byte mech string value []byte + qual byte } diff --git a/lib/spf/macro.go b/lib/spf/macro.go index f41f2e32..825be51a 100644 --- a/lib/spf/macro.go +++ b/lib/spf/macro.go @@ -34,14 +34,18 @@ const ( type macro struct { ref *Result - out []byte // mode is either mechanism "include", modifier "redirect", or // modifier "exp". - mode string - nright int - dels []byte - letter byte + mode string + + out []byte + dels []byte + + nright int + + letter byte + isReversed bool } diff --git a/lib/spf/result.go b/lib/spf/result.go index 34f98430..48ecb1db 100644 --- a/lib/spf/result.go +++ b/lib/spf/result.go @@ -16,18 +16,21 @@ import ( // Result contains the output of CheckHost function. type Result struct { - IP net.IP // The IP address of sender. + IP net.IP // The IP address of sender. + + Err string + Domain []byte // The domain address of sender from SMTP EHLO or MAIL FROM command. Sender []byte // The email address of sender. Hostname []byte - Code byte // Result of check host. - Err string senderLocal []byte // The local part of sender. senderDomain []byte // The domain part of sender. terms []byte // terms contains raw DNS RR that have SPF record. dirs []*directive mods []*modifier + + Code byte // Result of check host. } // newResult initialize new SPF result on single domain. |
