From c1029de8752543b8e82db93e5d709dc1e7601d6f Mon Sep 17 00:00:00 2001 From: Percy Wegmann Date: Thu, 21 Mar 2024 07:22:25 -0500 Subject: [PATCH] ipn/localapi: don't indent status response Doing indented JSON marshaling results in encoding/json allocating an internal buffer, so even when encoding directly to a writer, it still generates a lot of garbage. Updates tailscale/corp#18514 Signed-off-by: Percy Wegmann --- ipn/localapi/localapi.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ipn/localapi/localapi.go b/ipn/localapi/localapi.go index 41bfe2bd0..f6db3d4a4 100644 --- a/ipn/localapi/localapi.go +++ b/ipn/localapi/localapi.go @@ -1202,9 +1202,7 @@ func (h *Handler) serveStatus(w http.ResponseWriter, r *http.Request) { } else { st = h.b.StatusWithoutPeers() } - e := json.NewEncoder(w) - e.SetIndent("", "\t") - e.Encode(st) + json.NewEncoder(w).Encode(st) } func (h *Handler) serveDebugPeerEndpointChanges(w http.ResponseWriter, r *http.Request) {