refs.c: flatten get_ref_store() a bit
[gitweb.git] / xdiff / xemit.c
index b52b4b9c1ee3ba3c6b94594af68a275e458bebaf..8c88dbde3827ce9d1b5e4f95287513514b80fac1 100644 (file)
@@ -183,16 +183,14 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 
                                /*
                                 * We don't need additional context if
-                                * a whole function was added, possibly
-                                * starting with empty lines.
+                                * a whole function was added.
                                 */
-                               while (i2 < xe->xdf2.nrec &&
-                                      is_empty_rec(&xe->xdf2, i2))
+                               while (i2 < xe->xdf2.nrec) {
+                                       if (match_func_rec(&xe->xdf2, xecfg, i2,
+                                               dummy, sizeof(dummy)) >= 0)
+                                               goto post_context_calculation;
                                        i2++;
-                               if (i2 < xe->xdf2.nrec &&
-                                   match_func_rec(&xe->xdf2, xecfg, i2,
-                                                  dummy, sizeof(dummy)) >= 0)
-                                       goto post_context_calculation;
+                               }
 
                                /*
                                 * Otherwise get more context from the
@@ -239,7 +237,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
                        if (xche->next) {
                                long l = XDL_MIN(xche->next->i1,
                                                 xe->xdf1.nrec - 1);
-                               if (l <= e1 ||
+                               if (l - xecfg->ctxlen <= e1 ||
                                    get_func_line(xe, xecfg, NULL, l, e1) < 0) {
                                        xche = xche->next;
                                        goto post_context_calculation;