#1762·perkeep

pkg/schema: intern common string values in UnmarshalJSON?

Author: bradfitzCreated Nov 28, 2025Updated Nov 28, 2025
LabelsPerformance

Looks like we could probably save some allocs by interning the common string values in CamliType+ClaimType etc's UnmarshalJSON methods....

go
// CamliType is one of the valid "camliType" fields in a schema blob. See doc/schema.
type CamliType string

const (
	TypeBytes     CamliType = "bytes"
	TypeClaim     CamliType = "claim"
	TypeDirectory CamliType = "directory"
	TypeFIFO      CamliType = "fifo"
	TypeFile      CamliType = "file"
	TypeInode     CamliType = "inode"
	TypeKeep      CamliType = "keep"
	TypePermanode CamliType = "permanode"
	TypeShare     CamliType = "share"
	TypeSocket    CamliType = "socket"
	TypeStaticSet CamliType = "static-set"
	TypeSymlink   CamliType = "symlink"
)

// ClaimType is one of the valid "claimType" fields in a "claim" schema blob. See doc/schema/claims/.
type ClaimType string

const (
	SetAttributeClaim ClaimType = "set-attribute"
	AddAttributeClaim ClaimType = "add-attribute"
	DelAttributeClaim ClaimType = "del-attribute"