internal/pkg: cache computed identifiers

This eliminates duplicate identifier computations. The new implementation also significantly reduces allocations while computing identifier for a large dependency tree.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-15 22:05:24 +09:00
parent 088d35e4e6
commit 3499a82785
9 changed files with 276 additions and 199 deletions

View File

@@ -50,9 +50,11 @@ func NewHTTPGet(
// Kind returns the hardcoded [Kind] constant.
func (a *httpArtifact) Kind() Kind { return KindHTTPGet }
// Params returns the backing url string. Context is not represented as it does
// Params writes the backing url string. Client is not represented as it does
// not affect [Cache.Cure] outcome.
func (a *httpArtifact) Params() []byte { return []byte(a.url) }
func (a *httpArtifact) Params(ctx *IContext) {
ctx.GetHash().Write([]byte(a.url))
}
// Dependencies returns a nil slice.
func (a *httpArtifact) Dependencies() []Artifact { return nil }