1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2025-10-04 04:31:00 +00:00

compare: modernise compareEntry

The previous logic was overly complicated and can be simplified a lot
(especially now that we have helpful generic stdlib packages for dealing
with maps).

There are still several bugs in this, but the intention of this patch is
to just modernise the code without making any functional changes.
Bugfixes will come later.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
Aleksa Sarai 2025-09-16 11:51:50 +10:00
parent 02df712987
commit ed28104f71
No known key found for this signature in database
GPG key ID: 2897FAD2B7E9446F
2 changed files with 125 additions and 104 deletions

View file

@ -147,6 +147,15 @@ func (e Entry) AllKeys() []KeyVal {
return e.Keywords
}
func (e Entry) allKeysMap() map[Keyword]KeyVal {
all := e.AllKeys()
keyMap := make(map[Keyword]KeyVal, len(all))
for _, kv := range all {
keyMap[kv.Keyword()] = kv
}
return keyMap
}
// IsDir checks the type= value for this entry on whether it is a directory
func (e Entry) IsDir() bool {
for _, kv := range e.AllKeys() {