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:
parent
02df712987
commit
ed28104f71
2 changed files with 125 additions and 104 deletions
9
entry.go
9
entry.go
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue