From aa7e2873aa4da53fbaa4774fdd33f5af20c1afb0 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Mon, 30 Mar 2026 05:40:58 +0000 Subject: object/tree: Add helpers and cleanup --- object/tree/path_prefix.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 object/tree/path_prefix.go (limited to 'object/tree/path_prefix.go') diff --git a/object/tree/path_prefix.go b/object/tree/path_prefix.go new file mode 100644 index 00000000..ed658cee --- /dev/null +++ b/object/tree/path_prefix.go @@ -0,0 +1,19 @@ +package tree + +import ( + "bytes" + "slices" +) + +// HasPathPrefix reports whether path begins with prefix as whole components. +func HasPathPrefix(path, prefix [][]byte) bool { + if len(prefix) == 0 { + return true + } + + if len(path) < len(prefix) { + return false + } + + return slices.EqualFunc(path[:len(prefix)], prefix, bytes.Equal) +} -- cgit v1.3.1-10-gc9f91