Commit Diff


commit - 359b29cbe1fd2b48f3974ac65bf33933bd603715
commit + 467a993dc1da672ac3093104cbeae0dc22f978f9
blob - 65e95cd2003475de86231ea9a9e0e28b7251e3e0
blob + 82a44b8c680bcf2c6693dcaa405869824ac95696
--- lib/diff_main.c
+++ lib/diff_main.c
@@ -359,43 +359,48 @@ diff_algo_none(const struct diff_algo_config *algo_con
 			       0);
 
 	/* Add a chunk of equal lines, if any */
+	struct diff_atom *l = state->left.atoms.head;
+	unsigned int l_len = state->left.atoms.len;
+	struct diff_atom *r = state->right.atoms.head;
+	unsigned int r_len = state->right.atoms.len;
 	unsigned int equal_atoms = 0;
-	while (equal_atoms < state->left.atoms.len
-	       && equal_atoms < state->right.atoms.len) {
-		int r;
+
+	while (equal_atoms < l_len
+	       && equal_atoms < r_len) {
+		int err;
 		bool same;
-		r = diff_atom_same(&same, &state->left.atoms.head[equal_atoms],
-				   &state->right.atoms.head[equal_atoms]);
-		if (r)
-			return r;
+		err = diff_atom_same(&same, &l[equal_atoms],
+				   &r[equal_atoms]);
+		if (err)
+			return err;
 		if (!same)
 			break;
 		equal_atoms++;
 	}
 	if (equal_atoms) {
 		if (!diff_state_add_chunk(state, true,
-					  &state->left.atoms.head[0],
+					  &l[0],
 					  equal_atoms,
-					  &state->right.atoms.head[0],
+					  &r[0],
 					  equal_atoms))
 			return ENOMEM;
 	}
 
 	/* Add a "minus" chunk with all lines from the left. */
-	if (equal_atoms < state->left.atoms.len) {
+	if (equal_atoms < l_len) {
 		if (!diff_state_add_chunk(state, true,
-					  &state->left.atoms.head[equal_atoms],
-					  state->left.atoms.len - equal_atoms,
+					  &l[equal_atoms],
+					  l_len - equal_atoms,
 					  NULL, 0))
 		    return ENOMEM;
 	}
 
 	/* Add a "plus" chunk with all lines from the right. */
-	if (equal_atoms < state->right.atoms.len) {
+	if (equal_atoms < r_len) {
 		if (!diff_state_add_chunk(state, true,
 					  NULL, 0,
-					  &state->right.atoms.head[equal_atoms],
-					  state->right.atoms.len - equal_atoms))
+					  &r[equal_atoms],
+					  r_len - equal_atoms))
 		return ENOMEM;
 	}
 	return DIFF_RC_OK;