From 9461bd296caec1abb7da62adfa436b469d4a86f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 3 Dec 2025 11:54:03 +0000 Subject: [PATCH] all: replace cue.Value.Null with IsNull when we just need a bool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Null returns a full error when a cue.Value is not a null, which allocates unnecessarily when the caller just needs to have the boolean rather than the full error when it's not a null. Signed-off-by: Daniel Martí Change-Id: I5940530257b3fddfa51b97cfdbf5daf018604e87 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1227396 Reviewed-by: Matthew Sackman Unity-Result: CUE porcuepine TryBot-Result: CUEcueckoo --- encoding/openapi/build.go | 2 +- pkg/tool/exec/exec.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/encoding/openapi/build.go b/encoding/openapi/build.go index bc52f110f..01c07a03c 100644 --- a/encoding/openapi/build.go +++ b/encoding/openapi/build.go @@ -489,7 +489,7 @@ func (b *builder) disjunction(a []cue.Value, f typeFunc) { for _, v := range a { switch { - case v.Null() == nil: + case v.IsNull(): // TODO: for JSON schema, we need to fall through. nullable = true diff --git a/pkg/tool/exec/exec.go b/pkg/tool/exec/exec.go index e8a0d743f..db6197e66 100644 --- a/pkg/tool/exec/exec.go +++ b/pkg/tool/exec/exec.go @@ -46,7 +46,7 @@ func (c *execCmd) Run(ctx *task.Context) (res interface{}, err error) { // TODO: set environment variables, if defined. stream := func(name string) (stream cue.Value, ok bool) { c := ctx.Obj.LookupPath(cue.ParsePath(name)) - if err := c.Null(); c.Err() != nil || err == nil { + if c.Err() != nil || c.IsNull() { return } return c, true -- 2.51.2