aboutsummaryrefslogtreecommitdiff
path: root/object
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-13 15:54:01 +0000
committerGravatar Runxi Yu2026-06-13 15:54:01 +0000
commit4582b264616b9f77f3d1f4a147d586a77359abbb (patch)
treee985bb8ba8c0a55876f6f237963f07337498db46 /object
parentobject/store/memory: Don't copy on read (diff)
object/blob: Lifetimes
Diffstat (limited to 'object')
-rw-r--r--object/blob/parse.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/object/blob/parse.go b/object/blob/parse.go
index c013af96..1796d42f 100644
--- a/object/blob/parse.go
+++ b/object/blob/parse.go
@@ -2,7 +2,13 @@ package blob
// Parse decodes a blob object body.
//
-// Labels: Life-Independent.
+// The returned blob aliases body:
+// its Data shares the same backing array,
+// so the blob inherits body's lifetime
+// and must not be mutated unless body may be.
+// Use [Blob.Clone] for an independent copy.
+//
+// Labels: Life-Parent, Mut-No.
func Parse(body []byte) (*Blob, error) {
- return &Blob{Data: append([]byte(nil), body...)}, nil
+ return &Blob{Data: body}, nil
}