Re: [PATCH v9] json_writer: new routines to create JSON data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



git@xxxxxxxxxxxxxxxxx writes:


> +static void indent_pretty(struct json_writer *jw)
> +{
> +	int k;
> +
> +	if (!jw->pretty)
> +		return;
> +
> +	for (k = 0; k < jw->open_stack.len; k++)
> +		strbuf_addstr(&jw->json, "  ");
> +}

> +static void array_common(struct json_writer *jw)
> +{
> +	assert_in_array(jw);
> +	maybe_add_comma(jw);
> +
> +	if (jw->pretty)
> +		strbuf_addch(&jw->json, '\n');
> +	indent_pretty(jw);

Make it

	if (jw->pretty) {
		strbuf_addch(&jw->json, '\n');
		indent_pretty(jw);
	}

and lose "be noop unless jw->pretty" check from the indent function.

Most other codepaths that cares about pretty printing state use that
"I check and decide to (or not to) call helpers that unconditionally
do" pattern, and the way indent_pretty() is used in the patch stands
out like a sore thumb.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux