From a29a8c8396fc16af744a0abc86b5aca343aa620a Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sun, 19 Dec 2021 14:46:34 +0700 Subject: all: realign all structs This minimize storage size allocated by * hostBlocks: from 88 to 80 bytes (-8 bytes) * Environment: from 344 to 288 bytes (-56 bytes) --- environment.go | 15 +++++++++------ hosts_block.go | 6 ++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/environment.go b/environment.go index 21cefd9..3d1bede 100644 --- a/environment.go +++ b/environment.go @@ -53,16 +53,19 @@ const ( // Environment for running rescached. // type Environment struct { - dns.ServerOptions - WUIListen string `ini:"rescached::wui.listen"` - FileResolvConf string `ini:"rescached::file.resolvconf"` + HostsFiles map[string]*dns.HostsFile + Zones map[string]*dns.Zone + fileConfig string + FileResolvConf string `ini:"rescached::file.resolvconf"` + WUIListen string `ini:"rescached::wui.listen"` - Debug int `ini:"rescached::debug"` HostsBlocksRaw []string `ini:"rescached::hosts_block" json:"-"` HostsBlocks []*hostsBlock - HostsFiles map[string]*dns.HostsFile - Zones map[string]*dns.Zone + + dns.ServerOptions + + Debug int `ini:"rescached::debug"` } // diff --git a/hosts_block.go b/hosts_block.go index b879d05..3599acd 100644 --- a/hosts_block.go +++ b/hosts_block.go @@ -33,12 +33,14 @@ var hostsBlockSources = []*hostsBlock{{ }} type hostsBlock struct { + lastUpdated time.Time + Name string // Derived from hostname in URL. URL string LastUpdated string - IsEnabled bool - lastUpdated time.Time file string + + IsEnabled bool } func (hb *hostsBlock) init(sources []string) { -- cgit v1.3