Skip to content

Commit 324fbaa

Browse files
dschogitster
authored andcommitted
xdiff: avoid using the comma operator unnecessarily
The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. While the code in this patch used the comma operator intentionally (to avoid curly brackets around two statements, each, that want to be guarded by a condition), it is better to surround it with curly brackets and to use a semicolon instead. Signed-off-by: Johannes Schindelin <[email protected]> Acked-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0fbbb2c commit 324fbaa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

xdiff/xdiffi.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1,
211211
for (d = fmax; d >= fmin; d -= 2) {
212212
i1 = XDL_MIN(kvdf[d], lim1);
213213
i2 = i1 - d;
214-
if (lim2 < i2)
215-
i1 = lim2 + d, i2 = lim2;
214+
if (lim2 < i2) {
215+
i1 = lim2 + d;
216+
i2 = lim2;
217+
}
216218
if (fbest < i1 + i2) {
217219
fbest = i1 + i2;
218220
fbest1 = i1;
@@ -223,8 +225,10 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1,
223225
for (d = bmax; d >= bmin; d -= 2) {
224226
i1 = XDL_MAX(off1, kvdb[d]);
225227
i2 = i1 - d;
226-
if (i2 < off2)
227-
i1 = off2 + d, i2 = off2;
228+
if (i2 < off2) {
229+
i1 = off2 + d;
230+
i2 = off2;
231+
}
228232
if (i1 + i2 < bbest) {
229233
bbest = i1 + i2;
230234
bbest1 = i1;

0 commit comments

Comments
 (0)