{"thread":{"id":"49534","subject":"[PATCH] diff.c: pass sign_index to emit_line_ws_markup","startedAt":"2018-10-10T23:25:05Z","lastAt":"2018-10-12T09:37:15Z","messageCount":2,"participants":["Stefan Beller","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"360107","messageId":"20181010232459.251289-1-sbeller@google.com","threadId":"49534","inReplyTo":null,"subject":"[PATCH] diff.c: pass sign_index to emit_line_ws_markup","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-10T23:24:59Z","receivedAt":"2018-10-10T23:25:05Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Instead of passing the sign directly to emit_line_ws_markup, pass only the\nindex to lookup the sign in diff_options->output_indicators.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\nI still have this patch laying around, it simplifies the diff code\na tiny bit.\n\nStefan\n\n diff.c | 12 +++++-------\n 1 file changed, 5 insertions(+), 7 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex f0c7557b40..9e895f2191 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1202,10 +1202,11 @@ static void dim_moved_lines(struct diff_options *o)\n static void emit_line_ws_markup(struct diff_options *o,\n \t\t\t\tconst char *set_sign, const char *set,\n \t\t\t\tconst char *reset,\n-\t\t\t\tchar sign, const char *line, int len,\n+\t\t\t\tint sign_index, const char *line, int len,\n \t\t\t\tunsigned ws_rule, int blank_at_eof)\n {\n \tconst char *ws = NULL;\n+\tint sign = o->output_indicators[sign_index];\n \n \tif (o->ws_error_highlight & ws_rule) {\n \t\tws = diff_get_color_opt(o, DIFF_WHITESPACE);\n@@ -1285,8 +1286,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,\n \t\t\t\tset = diff_get_color_opt(o, DIFF_FILE_OLD);\n \t\t}\n \t\temit_line_ws_markup(o, set_sign, set, reset,\n-\t\t\t\t    o->output_indicators[OUTPUT_INDICATOR_CONTEXT],\n-\t\t\t\t    line, len,\n+\t\t\t\t    OUTPUT_INDICATOR_CONTEXT, line, len,\n \t\t\t\t    flags & (DIFF_SYMBOL_CONTENT_WS_MASK), 0);\n \t\tbreak;\n \tcase DIFF_SYMBOL_PLUS:\n@@ -1330,8 +1330,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,\n \t\t\tflags &= ~DIFF_SYMBOL_CONTENT_WS_MASK;\n \t\t}\n \t\temit_line_ws_markup(o, set_sign, set, reset,\n-\t\t\t\t    o->output_indicators[OUTPUT_INDICATOR_NEW],\n-\t\t\t\t    line, len,\n+\t\t\t\t    OUTPUT_INDICATOR_NEW, line, len,\n \t\t\t\t    flags & DIFF_SYMBOL_CONTENT_WS_MASK,\n \t\t\t\t    flags & DIFF_SYMBOL_CONTENT_BLANK_LINE_EOF);\n \t\tbreak;\n@@ -1375,8 +1374,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,\n \t\t\t\tset = diff_get_color_opt(o, DIFF_CONTEXT_DIM);\n \t\t}\n \t\temit_line_ws_markup(o, set_sign, set, reset,\n-\t\t\t\t    o->output_indicators[OUTPUT_INDICATOR_OLD],\n-\t\t\t\t    line, len,\n+\t\t\t\t    OUTPUT_INDICATOR_OLD, line, len,\n \t\t\t\t    flags & DIFF_SYMBOL_CONTENT_WS_MASK, 0);\n \t\tbreak;\n \tcase DIFF_SYMBOL_WORDS_PORCELAIN:\n-- \n2.19.0\n\n"},{"id":"360289","messageId":"nycvar.QRO.7.76.6.1810121136490.45@tvgsbejvaqbjf.bet","threadId":"49534","inReplyTo":"20181010232459.251289-1-sbeller@google.com","subject":"Re: [PATCH] diff.c: pass sign_index to emit_line_ws_markup","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-10-12T09:37:11Z","receivedAt":"2018-10-12T09:37:15Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Stefan,\n\nOn Wed, 10 Oct 2018, Stefan Beller wrote:\n\n> Instead of passing the sign directly to emit_line_ws_markup, pass only the\n> index to lookup the sign in diff_options->output_indicators.\n> \n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n> \n> I still have this patch laying around, it simplifies the diff code\n> a tiny bit.\n\nAnd I still like it (obviously, was my idea :-))\n\nThanks,\nDscho\n\n> \n> Stefan\n> \n>  diff.c | 12 +++++-------\n>  1 file changed, 5 insertions(+), 7 deletions(-)\n> \n> diff --git a/diff.c b/diff.c\n> index f0c7557b40..9e895f2191 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -1202,10 +1202,11 @@ static void dim_moved_lines(struct diff_options *o)\n>  static void emit_line_ws_markup(struct diff_options *o,\n>  \t\t\t\tconst char *set_sign, const char *set,\n>  \t\t\t\tconst char *reset,\n> -\t\t\t\tchar sign, const char *line, int len,\n> +\t\t\t\tint sign_index, const char *line, int len,\n>  \t\t\t\tunsigned ws_rule, int blank_at_eof)\n>  {\n>  \tconst char *ws = NULL;\n> +\tint sign = o->output_indicators[sign_index];\n>  \n>  \tif (o->ws_error_highlight & ws_rule) {\n>  \t\tws = diff_get_color_opt(o, DIFF_WHITESPACE);\n> @@ -1285,8 +1286,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,\n>  \t\t\t\tset = diff_get_color_opt(o, DIFF_FILE_OLD);\n>  \t\t}\n>  \t\temit_line_ws_markup(o, set_sign, set, reset,\n> -\t\t\t\t    o->output_indicators[OUTPUT_INDICATOR_CONTEXT],\n> -\t\t\t\t    line, len,\n> +\t\t\t\t    OUTPUT_INDICATOR_CONTEXT, line, len,\n>  \t\t\t\t    flags & (DIFF_SYMBOL_CONTENT_WS_MASK), 0);\n>  \t\tbreak;\n>  \tcase DIFF_SYMBOL_PLUS:\n> @@ -1330,8 +1330,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,\n>  \t\t\tflags &= ~DIFF_SYMBOL_CONTENT_WS_MASK;\n>  \t\t}\n>  \t\temit_line_ws_markup(o, set_sign, set, reset,\n> -\t\t\t\t    o->output_indicators[OUTPUT_INDICATOR_NEW],\n> -\t\t\t\t    line, len,\n> +\t\t\t\t    OUTPUT_INDICATOR_NEW, line, len,\n>  \t\t\t\t    flags & DIFF_SYMBOL_CONTENT_WS_MASK,\n>  \t\t\t\t    flags & DIFF_SYMBOL_CONTENT_BLANK_LINE_EOF);\n>  \t\tbreak;\n> @@ -1375,8 +1374,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,\n>  \t\t\t\tset = diff_get_color_opt(o, DIFF_CONTEXT_DIM);\n>  \t\t}\n>  \t\temit_line_ws_markup(o, set_sign, set, reset,\n> -\t\t\t\t    o->output_indicators[OUTPUT_INDICATOR_OLD],\n> -\t\t\t\t    line, len,\n> +\t\t\t\t    OUTPUT_INDICATOR_OLD, line, len,\n>  \t\t\t\t    flags & DIFF_SYMBOL_CONTENT_WS_MASK, 0);\n>  \t\tbreak;\n>  \tcase DIFF_SYMBOL_WORDS_PORCELAIN:\n> -- \n> 2.19.0\n> \n> \n"}]}