From d8477f19011692ef29d96e5bc56ef4fe3d407700 Mon Sep 17 00:00:00 2001 From: Producer Matt <58014742+ProducerMatt@users.noreply.github.com> Date: Thu, 7 Mar 2024 14:51:41 -0600 Subject: [PATCH] TxtBlock: split function definitions --- lib/txt_block.ex | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/txt_block.ex b/lib/txt_block.ex index c916100..4314909 100644 --- a/lib/txt_block.ex +++ b/lib/txt_block.ex @@ -23,20 +23,17 @@ defmodule TxtBlock do @type! t :: [] | nonempty_list(lazy(t())) | String.t() | lazy(block) @spec! to_str_list(t(), module()) :: S.str_list() - def to_str_list(item, service_name) when not is_list(item) do - case item do - txt when is_binary(txt) -> - txt + def to_str_list(txt, service_name) + when is_binary(txt), do: txt - {type, blk} -> - to_str_list(blk, service_name) - |> Service.txt_format(type, service_name) - end + def to_str_list({type, blk}, service_name) do + to_str_list(blk, service_name) + |> Service.txt_format(type, service_name) end - def to_str_list(blueprint, service_name) when is_list(blueprint) do + def to_str_list(blk, service_name) when is_list(blk) do # TODO: check performance of flattened vs non-flattened lists - List.foldl(blueprint, [], fn + List.foldl(blk, [], fn [], acc -> acc