Re: [PATCHv5 16/17] diff: buffer all output if asked to

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

 



On Wed, 24 May 2017 14:40:35 -0700
Stefan Beller <sbeller@xxxxxxxxxx> wrote:

> diff --git a/diff.h b/diff.h
> index 85948ed65a..fad1258556 100644
> --- a/diff.h
> +++ b/diff.h
> @@ -115,6 +115,42 @@ enum diff_submodule_format {
>  	DIFF_SUBMODULE_INLINE_DIFF
>  };
>  
> +/*
> + * This struct is used when we need to buffer the output of the diff output.
> + *
> + * NEEDSWORK: Instead of storing a copy of the line, add an offset pointer
> + * into the pre/post image file. This pointer could be a union with the
> + * line pointer. By storing an offset into the file instead of the literal line,
> + * we can decrease the memory footprint for the buffered output. At first we
> + * may want to only have indirection for the content lines, but we could also
> + * enhance the state for emitting prefabricated lines, e.g. the similarity
> + * score line or hunk/file headers would only need to store a number or path
> + * and then the output can be constructed later on depending on state.
> + */
> +struct diff_line {

Probably should be called diff_emission (or just emission), since these
may not be full lines.

Also, can this definition be in the .c file? Callers should use the
diff_emit_line() below, and not need to know how it is implemented
internally.

> +	const char *set;
> +	const char *reset;
> +	const char *line;
> +	int len;
> +	int sign;
> +	int add_line_prefix;
> +	enum {
> +		/*
> +		 * Emits [lineprefix][set][sign][reset] and then calls
> +		 * ws_check_emit which will output "line", marked up
> +		 * according to ws_rule.
> +		 */
> +		DIFF_LINE_WS,
> +
> +		/* Emits [lineprefix][set][sign] line [reset] */
> +		DIFF_LINE_ASIS,
> +
> +		/* Reloads the ws_rule; line contains the file name */
> +		DIFF_LINE_RELOAD_WS_RULE
> +	} state;
> +};
> +#define diff_line_INIT {NULL, NULL, NULL, 0, 0, 0}

Should be DIFF_LINE_INIT (capitalization), and {NULL} is sufficient, I
think.



[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]