diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-20 17:06:38 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-20 17:06:38 +0900 |
| commit | 31f0dd36df3ad5574ac4e9cab19b943f5c129ea2 (patch) | |
| tree | 4e7641ce495e60c4979e291f771a212f4ffe758c /container/absolute.go | |
| parent | 9aec2f46fe775e1e885df32ed77bdef125aa5391 (diff) | |
absolute: efficient equivalence check method
This is more efficient and makes the call site cleaner.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/absolute.go')
| -rw-r--r-- | container/absolute.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/container/absolute.go b/container/absolute.go index 8f1fa23b..637b035c 100644 --- a/container/absolute.go +++ b/container/absolute.go @@ -39,6 +39,15 @@ func (a *Absolute) String() string { return a.pathname } +func (a *Absolute) Is(v *Absolute) bool { + if a == nil && v == nil { + return true + } + return a != nil && v != nil && + a.pathname != zeroString && v.pathname != zeroString && + a.pathname == v.pathname +} + // NewAbs checks pathname and returns a new [Absolute] if pathname is absolute. func NewAbs(pathname string) (*Absolute, error) { if !isAbs(pathname) { |
