From 15f5f1dea48c3c2ee4bdb46159a457773f7f71ee Mon Sep 17 00:00:00 2001 From: preciz Date: Mon, 15 Jun 2026 12:26:20 +0200 Subject: [PATCH] Optimize Cookies.encode by avoiding string interpolation --- lib/plug/conn/cookies.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plug/conn/cookies.ex b/lib/plug/conn/cookies.ex index 525f987d..4781b2c3 100644 --- a/lib/plug/conn/cookies.ex +++ b/lib/plug/conn/cookies.ex @@ -104,11 +104,11 @@ defmodule Plug.Conn.Cookies do "key1=value1; path=/example; secure" """ def encode(key, opts \\ %{}) when is_map(opts) do - value = Map.get(opts, :value) + value = Map.get(opts, :value) || "" path = Map.get(opts, :path, "/") IO.iodata_to_binary([ - "#{key}=#{value}; path=#{path}", + key, ?=, value, "; path=", path, emit_if(opts[:domain], &["; domain=", &1]), emit_if(opts[:max_age], &encode_max_age(&1, opts)), emit_if(Map.get(opts, :secure, false), "; secure"),